Inductive ordered_composite: list (positive * composite) -> Prop :=
| ordered_composite_nil: ordered_composite nil
| ordered_composite_cons: forall i co l,
Forall (relative_defined_type l) (map snd (co_members co)) ->
ordered_composite l ->
ordered_composite ((i, co) :: l).
Module composite_reorder.
(* Use merge sort instead *)
(* Sort rank from higher to lower *)
Module CompositeRankOrder <: TotalLeBool.
Definition t := (positive * composite)%type.
Definition leb (x y: t) := Nat.leb (co_rank (snd y)) (co_rank (snd x)).

Theorem leb_trans: Transitive (fun x y => is_true (leb x y)).
End CompositeRankOrder.