let rec insert cmp e = function | [] -> [e] | h :: t as l -> if cmp e h <= 0 then e :: l else h :: insert cmp e tlet rec sort cmp = function | [] -> [] | h :: t -> insert cmp h (sort cmp t)let length_sort lists = let lists = List.map (fun list -> List.length list, list) lists in let lists = sort (fun a b -> compare (fst a) (fst b)) lists in List.map snd lists;;
I want to know how work this fun a b -> compare (fst a) (fst b),compare return 1 or -1, and what will give as variable to sort?and List.map snd lists will remove the first element of every list in the lists?