(* I want an order where the odd numbers come first! *) module IP = struct type t = int let compare x y = let o x = x land 1 in if (o x) = (o y) then x-y else (o y)-(o x) end;; module IS = Set.Make(IP);; let ss = ref IS.empty;; for i=0 to 10 do ss := IS.add i !ss done;; IS.elements !ss;; (* - : IS.elt list = [1; 3; 5; 7; 9; 0; 2; 4; 6; 8; 10] *)