In the interactive portrait plot, would it be available to add below function replacing the python’s default sorting?
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 l
Above function is what that I have used for creating my own portrait plot before your modal capability has become available. It sorts labels more in recognizable way.
For example, default sorted sorts as below:
A_r10i1p1
A_r1i1p1
A_r20i1p1
A_r2i1p1
A_r3i1p1
And the function I implemented sorts as below:
A_r1i1p1
A_r2i1p1
A_r3i1p1
A_r10i1p1
A_r20i1p1
I guess the right place might be in click/click_plots/portrait_plots.py, line 174 and 176 where sorted has been used, but would be nicer if you could confirm this for me.
Below is for actual use example.
>>> a=['a_1', 'a_11', 'a_2']
>>> sorted(a)
['a_1', 'a_11', 'a_2']
>>> 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 l
>>> sort_human(a)
['a_1', 'a_2', 'a_11']
>>>
In the interactive portrait plot, would it be available to add below function replacing the python’s default sorting?
Above function is what that I have used for creating my own portrait plot before your modal capability has become available. It sorts labels more in recognizable way.
For example, default
sortedsorts as below:A_r10i1p1
A_r1i1p1
A_r20i1p1
A_r2i1p1
A_r3i1p1
And the function I implemented sorts as below:
A_r1i1p1
A_r2i1p1
A_r3i1p1
A_r10i1p1
A_r20i1p1
I guess the right place might be in
click/click_plots/portrait_plots.py, line 174 and 176 wheresortedhas been used, but would be nicer if you could confirm this for me.Below is for actual use example.