write a function sort3 type real real real real that retu
write a function sort3 type real × real × real -> real that returns a list of three real numbers in sorted order with smallest first sml
Solution
main.sml
fun min3Real (a:real, b:real, c:real) = if a <= b andalso a <= c then a else if b <= a andalso b <= c then b else c;
 fun max3Real (a, b, c) = if a >= b andalso a >= c then a else if b >= a andalso b >= c then b else c;
 fun min2 (a:real, b:real) = if a <= b then a else b;
 fun sort3 (a, b, c) =
 let fun notMins (a, b, c) = if min3Real (a,b,c) = a then (b,c)
                               else if min3Real (a,b,c) = b then (a,c)
                               else if min3Real (a,b,c) = c then (a,b)
                               else (a,b)
in
     [min3Real (a,b,c), min2 (notMins (a,b,c)), max3Real (a,b,c)]
 end;

