From fd402e9248f32bd79c4527d7d2cec518d1079586 Mon Sep 17 00:00:00 2001 From: Alexanderlacuna Date: Fri, 6 Nov 2020 11:02:05 +0300 Subject: modify natural_sort and return list to avoid having side effect --- wqflask/wqflask/show_trait/SampleList.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'wqflask') 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 -- cgit v1.2.3