diff hgext/churn.py @ 18369:2150e70c0ee1

churn: sort users with same churn by name This makes the output order well-defined and improves code readability.
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 12 Dec 2012 02:38:14 +0100
parents 434e5bd615fc
children 68f7129af6a8
line wrap: on
line diff
--- a/hgext/churn.py	Wed Dec 12 02:38:14 2012 +0100
+++ b/hgext/churn.py	Wed Dec 12 02:38:14 2012 +0100
@@ -144,8 +144,10 @@
     if not rate:
         return
 
-    sortkey = ((not opts.get('sort')) and (lambda x: -sum(x[1])) or None)
-    rate.sort(key=sortkey)
+    if opts.get('sort'):
+        rate.sort()
+    else:
+        rate.sort(key=lambda x: (-sum(x[1]), x))
 
     # Be careful not to have a zero maxcount (issue833)
     maxcount = float(max(sum(v) for k, v in rate)) or 1.0