title: Sorting a list in Erlang
body: <p>How does one sort a list in Erlang depending on a tag for each element?</p>
  
  <p>If I have a process which loops and receives a single value from multiple processes and then I want to arrange the list according to the tag(which is an index) as an element is received.</p>
  
  <p>How does one do this without using BIFs?</p>
  
  <p>I currently do the following but would like to arrange the list when an element is added, like an insertion sort using the tags.</p>
  
  <pre><code>fibLoop(calcData) -&gt;
  receive
   {Number, Tag} -&gt;
   fibLoop([{Number, Tag}|calcData]);
  </code></pre>