1 # from http://stackoverflow.com/questions/4836710/does-python-have-a-built-in-function-for-string-natural-sort
2 # modified by Diane Trout
6 def natural_sort_key(s, _nsre=re.compile('([0-9]+)')):
7 if isinstance(s, type("")) or isinstance(s, type(u"")):
8 return [int(text) if text.isdigit() else text.lower()
9 for text in re.split(_nsre, s)]
10 elif isinstance(s, int):
13 raise ValueError("Unsupported type %s for input %s" % (type(s), s))