-# Sort mclasses by their name
-class MClassNameSorter
- super AbstractSorter[MClass]
- redef fun compare(a, b) do return a.name <=> b.name
- init do end
-end
-
-# Sort mclassdefs by their name
-class MClassDefNameSorter
- super AbstractSorter[MClassDef]
- redef fun compare(a, b) do return a.mclass.name <=> b.mclass.name
- init do end
-end
-
-# Sort mproperties by their name
-class MPropertyNameSorter
- super AbstractSorter[MProperty]
- redef fun compare(a, b) do return a.name <=> b.name
- init do end
-end
-
-# Sort mpropdefs by their name
-class MPropDefNameSorter
- super AbstractSorter[MPropDef]
- redef fun compare(a, b) do return a.mproperty.name <=> b.mproperty.name
- init do end
+# Sort MConcerns based on the module importation hierarchy ranking
+# see also: `MConcern::concern_rank` and `MConcern::booster_rank`
+#
+# Comparison is made with the formula:
+#
+# ~~~nitish
+# a.concern_rank + a.booster_rank <=> b.concern_rank + b.booster_ran
+# ~~~
+#
+# If both `a` and `b` have the same ranking,
+# ordering is based on lexicographic comparison of `a.name` and `b.name`
+class MConcernRankSorter
+ super Comparator
+ redef type COMPARED: MConcern
+
+ redef fun compare(a, b) do
+ if a.concern_rank == b.concern_rank then
+ return a.name <=> b.name
+ end
+ return a.concern_rank + a.booster_rank <=> b.concern_rank + b.booster_rank
+ end