Use proper sorting
This commit is contained in:
1 parent
e51e6b2171
commit
d16dd7c75d
3 files changed
+10
-19
No files matched your search
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user