spacepy.toolbox.human_sort¶
-
spacepy.toolbox.
human_sort
(l)[source]¶ Sort the given list in the way that humans expect. http://www.codinghorror.com/blog/2007/12/sorting-for-humans-natural-sort-order.html
Parameters: l : list
list of objects to human sort
Returns: out : list
sorted list
Examples
>>> import spacepy.toolbox as tb >>> dat = ['r1.txt', 'r10.txt', 'r2.txt'] >>> dat.sort() >>> print dat ['r1.txt', 'r10.txt', 'r2.txt'] >>> tb.human_sort(dat) ['r1.txt', 'r2.txt', 'r10.txt']