Sanchime.Learn/Algrithms/Sorts/QuickSort.fs

11 lines
308 B
Forth

namespace Sanchime.Algrithm.Sort
[<AutoOpen>]
module Quick =
let rec qsort sorted = function
| [] -> []
| [x] -> [x]
| x::xs ->
let smaller,larger = xs |> List.partition (fun i -> sorted i x)
(qsort sorted smaller) @ [x] @ qsort sorted larger