MCPcopy Create free account
hub / github.com/NVlabs/SPADE / natural_keys

Function natural_keys

util/util.py:158–164  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

156
157
158def 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
167def natural_sort(items):

Callers

nothing calls this directly

Calls 1

atoiFunction · 0.85

Tested by

no test coverage detected