let rec qsort = function
| [] -> []
| x :: xs ->
let smaller = List.filter (fun a -> a <= x) xs
let larger = [for a in xs do if a > x then yield a]
qsort smaller @ [x] @ qsort larger
let unsorted = [5; 2; 1; 4; 3]
let sorted = qsort unsorted
printfn "%A" unsorted
printfn "%A" sorted
To embed this project on your website, copy the following code and paste it into your website's HTML: