alist.sort(key=natural_keys) sorts in human order http://nedbatchelder.com/blog/200712/human_sorting.html (See Toothy's implementation in the comments)
(text)
| 156 | |
| 157 | |
| 158 | def natural_keys(text): |
| 159 | ''' |
| 160 | alist.sort(key=natural_keys) sorts in human order |
| 161 | http://nedbatchelder.com/blog/200712/human_sorting.html |
| 162 | (See Toothy's implementation in the comments) |
| 163 | ''' |
| 164 | return [atoi(c) for c in re.split('(\d+)', text)] |
| 165 | |
| 166 | |
| 167 | def natural_sort(items): |