(2.9) Make NiceSort treat integers well
authorHrvoje Ribicic <riba@google.com>
Tue, 25 Feb 2014 16:25:29 +0000 (16:25 +0000)
committerDimitris Aragiorgis <dimara@grnet.gr>
Thu, 27 Mar 2014 08:01:09 +0000 (10:01 +0200)
NiceSort is invoked on arrays that may contain strings, but in other
situations can contain ints as well. As this surprisingly makes sense,
add a tiny modification to make NiceSort work in these conditions.

Signed-off-by: Hrvoje Ribicic <riba@google.com>
Reviewed-by: Jose A. Lopes <jabolopes@google.com>

lib/utils/algo.py

index ec8ce34..ea1c688 100644 (file)
@@ -110,7 +110,7 @@ def NiceSortKey(value):
 
   """
   return [_NiceSortTryInt(grp)
-          for grp in _SORTER_RE.match(value).groups()]
+          for grp in _SORTER_RE.match(str(value)).groups()]
 
 
 def NiceSort(values, key=None):