Use proper sorting

This commit is contained in:
Ruud
2014-03-06 21:30:59 +01:00
parent e51e6b2171
commit d16dd7c75d
3 changed files with 10 additions and 19 deletions
+3 -10
View File
@@ -214,16 +214,9 @@ def tryFloat(s):
return float(s)
except: return 0
def natsortKey(s):
return map(tryInt, re.findall(r'(\d+|\D+)', s))
def natcmp(a, b):
a2 = natsortKey(a)
b2 = natsortKey(b)
return (a2 > b2) - (a2 < b2)
def natsortKey(string_):
"""See http://www.codinghorror.com/blog/archives/001018.html"""
return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_)]
def toIterable(value):