title: standard ml sorting 3 elements
body: <p>I'm trying to make a standard ml function which takes 3 elements as input and returns a  sorted list which is sorted from smallest to largest. I used 3 helper methods that gets me the min, max and the mid elements. the codes are below:</p>
  
  <pre><code>- fun min3 (a, b, c):real = 
      if a &lt; b andalso a &lt; c then a
          else if b &lt; a andalso b &lt; c then b
          else c;
  
  - fun mid3 (a, b, c):real = 
      if (a &lt; b andalso a &gt; c) orelse (a &gt; b andalso a &lt; c) then a
          else if (b &lt; a andalso b &gt; c) orelse (b &gt; a andalso b &lt; c) then b
          else c;
  
  - fun max3 (a, b, c):real = 
      if a &gt; b andalso a &gt; c then a
      else if b &gt; a andalso b &gt; c then b
          else c;
  
  - fun sort3 (a, b, c):real = 
      min3(a, b, c)::mid3(a, b, c)::max3(a, b, c)::[];
  </code></pre>
  
  <p>the following worked perfectly when dealing with ints, but when i changed them to reals, the helper methods returned the correct results but i get error when typing the sort method which is the following (couldnt copy the error text so i took a screen shot) : </p>
  
  <p><img src="https://i.stack.imgur.com/smTl1.jpg" alt="enter image description here"></p>
  
  <p>what could be wrong in the code?
  Thanks</p>
  
  <p>Also, is there another way of sorting 3 elements other than the way i posted here or not?</p>