let rec qsort = function | [] -> [] | (x:int)::xs -> let left = List.choose (fun elem -> if elem<=x then Some(elem) else None) xs let right = List.choose (fun elem -> if elem>x then Some(elem) else None) xs qsort left @ [x] @ qsort right let result = qsort [1;8;3;4;7;6;2;9;5;1;5;6;7;8;3;4;5;6;3] printfn "%A" result let rec qsort = function | [] -> [] | (x:int)::xs -> let left = List.filter (fun elem -> elem<=x) xs let right = List.filter (fun elem -> elem>x) xs qsort left @ [x] @ qsort right let result = qsort [1;8;3;4;7;6;2;9;5;1;5;6;7;8;3;4;5;6;3] printfn "%A" result