From fe1b463d7e68d9be32053e979d630884563d7350 Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 20 Jul 2015 20:38:02 +0200 Subject: [PATCH] maildir-zero: sort by count --- maildir-zero | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/maildir-zero b/maildir-zero index 719a01c..97db7ee 100755 --- a/maildir-zero +++ b/maildir-zero @@ -37,6 +37,7 @@ def mailbox_name(maildir, root): ignore_zero = True ignore = [r'spam'] +sort_by_count = True root = os.path.expanduser('~/Maildir') @@ -53,5 +54,12 @@ for maildir in maildirs(root): counts[name] = all_ -for name in sorted(counts.keys()): - print('{:30} {:5d}'.format(name, counts[name])) +if sort_by_count: + key = lambda i: i[1] + reverse = True +else: + key = lambda i: i[0] + reverse = False + +for name, count in sorted(counts.items(), key=key, reverse=reverse): + print('{:30} {:5d}'.format(name, count))