From 3ce48cad6c9a3cb0a96fae28fe292b1694d411c6 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 3 Dec 2014 23:16:13 -0500 Subject: [PATCH] nitls: correctly sort by names with --tree Signed-off-by: Jean Privat --- src/nitls.nit | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/nitls.nit b/src/nitls.nit index e50d40c..9bfafd7 100644 --- a/src/nitls.nit +++ b/src/nitls.nit @@ -88,6 +88,24 @@ class ProjTree end end +class AlphaEntityComparator + super Comparator + fun nameof(a: COMPARED): String + do + if a isa MGroup then + return a.name + else if a isa ModulePath then + return a.name + else + abort + end + end + redef fun compare(a,b) + do + return nameof(a) <=> nameof(b) + end +end + var tc = new ToolContext var opt_keep = new OptionBool("Ignore errors and files that are not a Nit source file", "-k", "--keep") @@ -169,7 +187,7 @@ if opt_tree.value then end end end - ot.sort_with(new CachedAlphaComparator) + ot.sort_with(new AlphaEntityComparator) ot.write_to(stdout) end -- 1.7.9.5