Profile sorting

This commit is contained in:
Ruud
2011-09-07 17:21:49 +02:00
parent 85c3b16e69
commit 6940477e48
5 changed files with 162 additions and 15 deletions
+11
View File
@@ -1,5 +1,6 @@
import hashlib
import os.path
import re
def isDict(object):
return isinstance(object, dict)
@@ -41,3 +42,13 @@ def cleanHost(host):
host += '/'
return host
def tryInt(s):
try: return int(s)
except: return s
def natsortKey(s):
return map(tryInt, re.findall(r'(\d+|\D+)', s))
def natcmp(a, b):
return cmp(natsortKey(a), natsortKey(b))