Jump to content

Sorting algorithms/Insertion sort: Difference between revisions

added standard ml
(added standard ml)
Line 365:
 
(insertion-sort '(6 8 5 9 3 2 1 4 7))</lang>
 
=={{header|Standard ML}}==
<lang sml>fun insertion_sort cmp = let
fun insert (x, []) = [x]
| insert (x, y::ys) =
case cmp (x, y) of GREATER => y :: insert (x, ys)
| _ => x :: y :: ys
in
foldl insert []
end;
 
insertion_sort Int.compare [6,8,5,9,3,2,1,4,7];</lang>
 
=={{header|UnixPipes}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.