+redef class MAttribute
+ # Is this attribute nullable for sure?
+ #
+ # This mean that its introduction is declarred with a nullable static type
+ # since attributes are invariant this will work on most cases
+ # attributes with static type anchored with a virtual type are not "nullable for-sure"
+ # because this type can be redefined in subclasses
+ fun is_nullable: Bool do return intro.static_mtype isa MNullableType
+end
+
+redef class MClassDef
+ # modifiers are keywords like redef, private etc.
+ fun modifiers: Array[String] do
+ var res = new Array[String]
+ if not is_intro then
+ res.add "redef"
+ else
+ res.add mclass.visibility.to_s
+ end
+ res.add mclass.kind.to_s
+ return res
+ end
+end
+
+redef class MPropDef
+ # modifiers are keywords like redef, private etc.
+ fun modifiers: Array[String] do
+ var res = new Array[String]
+ if not is_intro then
+ res.add "redef"
+ else
+ res.add mproperty.visibility.to_s
+ end
+ var mprop = self
+ if mprop isa MVirtualTypeDef then
+ res.add "type"
+ else if mprop isa MMethodDef then
+ if mprop.is_abstract then
+ res.add "abstract"
+ else if mprop.is_intern then
+ res.add "intern"
+ end
+ if mprop.mproperty.is_init then
+ res.add "init"
+ else
+ res.add "fun"
+ end
+ end
+ return res
+ end
+end
+
+
+# Sorters
+
+# Sort mmodules by their name
+class MModuleNameSorter
+ super AbstractSorter[MModule]
+ redef fun compare(a, b) do return a.name <=> b.name
+ init do end
+end
+
+# 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
+end