I have a problem with sorting my strings which are stored in a list. The string is actually a path/filename of a measurement and looks e.g. like this:
'Data\Test1\Test1_<SomeParametersOfTheMeasurement>_-10_step1.txt'
-10
stands for the temperature of the measurement. The temperature ranges from -20 to 80 °C (2 °C steps in between) -> 1st condtion I want to sort my strings from -20 to 80.step1
indicates the test number at each temperature. At each temperature I perform at least 20 test runs -> 2nd condition sort strings from 1 to 20.
My list should then look like this:
meas_files = [
'...._-20_step1.txt',
'...._-20_step2.txt',
'...._-20_step3.txt',
'...'
'...._-20_step20.txt',
'...._-18_step1.txt',
'...._-18_step2.txt',
'...._-18_step3.txt',
'...'
'...._-18_step20.txt',
'...._-16_step1.txt',
'...._-16_step2.txt',
'...._-16_step3.txt',
'...'
'...'
'...'
'...._80_step20.txt']
I have tried following: list(Tcl().call('lsort', '-dict', meas_files))
(one command I have used for sorting the list by step numbers) but this resulted in sorting the steps numbers right but it started with -2 to -20 and continued with 0 to 80 °C:
meas_files = [
'...._-2_step1.txt',
'...._-2_step2.txt',
'...._-2_step3.txt',
'...'
'...._-2_step20.txt',
'...._-4_step1.txt',
'...._-4_step2.txt',
'...._-4_step3.txt',
'...'
'...._-4_step20.txt',
'...._-6_step1.txt',
'...._-6_step2.txt',
'...._-6_step3.txt',
'...'
'...'
'...'
'...._80_step20.txt']
I hope my problem is understandable to you. Thank you very much in advance for your help.
Martin