bugfix/better readable

This commit is contained in:
Martin Diehl 2020-11-29 08:58:48 +01:00
parent c712332e87
commit f48f5cb0e8
1 changed files with 6 additions and 5 deletions

View File

@ -121,6 +121,10 @@ class Result:
True is equivalent to [*], False is equivalent to []
"""
def natural_sort(key):
convert = lambda text: int(text) if text.isdigit() else text
return [ convert(c) for c in re.split('([0-9]+)', key) ]
# allow True/False and string arguments
if datasets is True:
datasets = ['*']
@ -154,11 +158,11 @@ class Result:
self.selection[what] = valid
elif action == 'add':
add = existing.union(valid)
add_sorted = sorted(add, key=lambda x: int("".join([i for i in x if i.isdigit()])))
add_sorted = sorted(add, key=natural_sort)
self.selection[what] = add_sorted
elif action == 'del':
diff = existing.difference(valid)
diff_sorted = sorted(diff, key=lambda x: int("".join([i for i in x if i.isdigit()])))
diff_sorted = sorted(diff, key=natural_sort)
self.selection[what] = diff_sorted
@ -329,9 +333,6 @@ class Result:
raise PermissionError('Rename operation not permitted')
# def datamerger(regular expression to filter groups into one copy)
def place(self,datasets,constituent=0,tagged=False,split=True):
"""
Distribute datasets onto geometry and return Table or (split) dictionary of Tables.