diff options
author | Alexanderlacuna | 2020-11-06 11:02:05 +0300 |
---|---|---|
committer | Alexanderlacuna | 2020-11-06 11:02:05 +0300 |
commit | fd402e9248f32bd79c4527d7d2cec518d1079586 (patch) | |
tree | 8a785232ce9bfd6acabf18164f864c3b7e9be374 /wqflask | |
parent | 6b23bf4a0698339a1c7672b8d84dfef9b9066a79 (diff) | |
download | genenetwork2-fd402e9248f32bd79c4527d7d2cec518d1079586.tar.gz |
modify natural_sort and return list to avoid having side effect
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/show_trait/SampleList.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/wqflask/wqflask/show_trait/SampleList.py b/wqflask/wqflask/show_trait/SampleList.py index 37c1d6d5..6a056144 100644 --- a/wqflask/wqflask/show_trait/SampleList.py +++ b/wqflask/wqflask/show_trait/SampleList.py @@ -162,7 +162,7 @@ class SampleList(object): return first_attr_col -def natural_sort(list, key=lambda s: s): +def natural_sort(a_list, key=lambda s: s): """ Sort the list into natural alphanumeric order. """ @@ -170,4 +170,8 @@ def natural_sort(list, key=lambda s: s): def convert(text): return int(text) if text.isdigit() else text return lambda s: [convert(c) for c in re.split('([0-9]+)', key(s))] sort_key = get_alphanum_key_func(key) - list.sort(key=sort_key)
\ No newline at end of file + + sorted_list=sorted(a_list,key=sort_key) + + return sorted_list +
\ No newline at end of file |