Sort a list of strings based on digit and non-digit groupings.
Given a list of names ['a1', 'a10', 'a11', 'a2'] this
function will sort the list in the logical order ['a1', 'a2',
'a10', 'a11'] .
The sort algorithm breaks each name in groups of either only-digits or
no-digits. Only the first eight such groups are considered, and after
that we just use what's left of the string.
- Parameters:
values (list) - the names to be sorted
key (callable or None) - function of one argument to extract a comparison key from each
list element, must return string
- Returns: list
- a copy of the name list sorted with our algorithm
|