let rec partition f = function
  | [] -> [], []
  | x::xs -> 
    let ys, zs = partition f xs
    if f x 
      then x::ys, zs
      else ys, x::zs
    
let rec qsort = function
  | [] -> []
  | p::xs -> 
    let lt, gt = partition (fun x -> x <= p) xs
    (qsort lt) @ [p] @ (qsort gt)   

let li = [5;1;4;2;3]
printfn "%A" li
printfn "%A" (qsort li)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: