-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
kind/featureCategorizes issue as related to feature requestCategorizes issue as related to feature request
Milestone
Description
Replacing python's default sorting to more human recognizable way.
import copy
import re
def sort_human(input_list):
l = copy.copy(input_list)
convert = lambda text: float(text) if text.isdigit() else text
alphanum = lambda key: [ convert(c) for c in re.split('([-+]?[0-9]*\.?[0-9]*)', key) ]
l.sort( key=alphanum )
return lExample:
>>> a=['a_1', 'a_11', 'a_2']
>>> sorted(a)
['a_1', 'a_11', 'a_2']
>>> sort_human(a)
['a_1', 'a_2', 'a_11']
Further detail: PCMDI/click#10
Metadata
Metadata
Assignees
Labels
kind/featureCategorizes issue as related to feature requestCategorizes issue as related to feature request