title: Haskell, inserting into an ordered list
body: <p>I am beginning to learn about Haskell and have been closely following the guides at <a href="http://learnyouahaskell.com" rel="nofollow">http://learnyouahaskell.com</a> and the documentation at <a href="https://wiki.haskell.org/How_to_work_on_lists" rel="nofollow">https://wiki.haskell.org/How_to_work_on_lists</a>. I have been working with nodes and binary trees as of late and have run into a problem that I cannot seem to figure out the correct syntax for. </p>
  
  <p>If I have an ordered list of nodes:</p>
  
  <pre><code>[(2 , Nil, Nil), (4, Nil, Nil), (10, Nil, Nil)]
  </code></pre>
  
  <p>And I want to insert a new node <code>(3, Nil, Nil)</code> into the list so that it could be represented as:</p>
  
  <pre><code>[(2, Nil, Nil), (3, Nil, Nil),(4, Nil, Nil), (10, Nil, Nil)]
  </code></pre>
  
  <p>What is the most elegant solution to do this? From what I have read <a href="https://wiki.haskell.org/How_to_work_on_lists" rel="nofollow">here</a> it looks as if you have to split the list in two parts once you detect the correct position but as a beginner im not sure how to do this. Obviously the pseudo code would be something a long the lines of <code>For every Node in the list, compare its number value versus the count value of the new Node . Once this value is greater than  or equal to the current index, split the list into two parts (a and b) and then combine the list in this order a ++ [newElement] ++ b</code>.</p>
  
  <p>In my mind (again, at a beginner level) when trying to implement this it would look like:</p>
  
  <p>sortedInsert </p>