let sort predicate examples =
(* loop over all data we have *)
let rec loop examples akku =
match examples with
[] ->
akku
| examples ->
(* get the first category *)
let category = predicate (List.hd examples) in
(* get all data in this category *)
let filter x = (predicate x) = category in
let filtered = List.filter filter examples in
(* get the rest *)
let rest = List.filter (fun x -> not (filter x)) examples in
(* continue with the rest *)
loop rest (filtered :: akku)
in
loop examples []