All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Randy Dunlap <rdunlap@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH Y.A. RESEND] MAINTAINERS: fix alpha. ordering
Date: Thu, 27 Jul 2017 17:30:07 -0700	[thread overview]
Message-ID: <1501201807.5368.31.camel@perches.com> (raw)
In-Reply-To: <CA+55aFxw1fSZ-YoOY_pLFwbu2q+eZFg00+H6YBAq6tGOgonD=w@mail.gmail.com>

On Sun, 2017-07-23 at 16:14 -0700, Linus Torvalds wrote:
> On Sun, Jul 23, 2017 at 1:00 PM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> > 
> > Anyway, clearly my script showed something. I think my script is still
> > doing the right thing, it's just that the input is questionable.
> 
> I added a few actual checks for the error cases to the script, fixed
> up the problems, and committed the end result.
> 
> My perl skills are still very dubious, so I'm not proud of the script,
> but it's there as "scripts/parse-mainainers.pl" now. The "output
> sorted result" part could *easily* be changed into "output sorted
> result into separate files based on the first word of the header" or
> something.
> 
> But in the meantime, at least that MAINTAINERS file should _really_ be
> alpha-sorted now.

Maybe add a reordering of the patterns so that each pattern list
is in a specific order too

---
 scripts/parse-maintainers.pl | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/scripts/parse-maintainers.pl b/scripts/parse-maintainers.pl
index a0fe34349b24..03e7405af1a3 100644
--- a/scripts/parse-maintainers.pl
+++ b/scripts/parse-maintainers.pl
@@ -4,7 +4,7 @@ use strict;
 
 my %map;
 
-# sort comparison function
+# sort comparison functions
 sub by_category($$) {
     my ($a, $b) = @_;
 
@@ -18,17 +18,45 @@ sub by_category($$) {
     $a cmp $b;
 }
 
+sub by_pattern($$) {
+    my ($a, $b) = @_;
+    my $preferred_order = 'MRPLWQTBSKCFX';
+
+    my $rtn;
+    $a = uc(substr($a, 0, 1));
+    $b = uc(substr($b, 0, 1));
+
+    my $a_index = index($preferred_order, $a);
+    my $b_index = index($preferred_order, $b);
+
+    $a_index = 1000 if ($a_index == -1);
+    $b_index = 1000 if ($b_index == -1);
+
+    if ($a_index < $b_index) {
+	return -1;
+    } elsif ($a_index == $b_index) {
+	return 0;
+    } else {
+	return 1;
+    }
+}
+
 sub alpha_output {
     my $key;
-    my $sort_method = \&by_category;
     my $sep = "";
 
-    foreach $key (sort $sort_method keys %map) {
+    foreach $key (sort by_category keys %map) {
         if ($key ne " ") {
             print $sep . $key . "\n";
             $sep = "\n";
         }
-        print $map{$key};
+	if ($key eq " ") {
+	    print $map{$key};
+	} else {
+	    foreach my $pattern (sort by_pattern split('\n', $map{$key})) {
+		print($pattern . "\n");
+	    }
+	}
     }
 }
 

  parent reply	other threads:[~2017-07-28  0:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-21 20:32 [PATCH Y.A. RESEND] MAINTAINERS: fix alpha. ordering Randy Dunlap
2017-07-22  2:01 ` Linus Torvalds
2017-07-23 19:49 ` Linus Torvalds
2017-07-23 20:00   ` Linus Torvalds
2017-07-23 20:10     ` Joe Perches
2017-07-23 23:14     ` Linus Torvalds
2017-07-24  1:38       ` Joe Perches
2017-07-28  0:30       ` Joe Perches [this message]
2017-07-28  2:43         ` Linus Torvalds
2017-07-28  3:12           ` Joe Perches
2017-07-28 22:30             ` Linus Torvalds
2017-07-29  1:08               ` Joe Perches
2017-07-29 17:46               ` Joe Perches
2017-07-23 20:05   ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1501201807.5368.31.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.