I want to know how I can sort the filenames as they are in the directory. For example, I have the following names:
1_00000_6.54.csv
2_00000_1.70.csv
3_00000_1.70.csv
...
10_00000_1.70.csv
11_00000_1.70.csv
...
With the following python code I get the following order:
def get_pixelist(path):
return [os.path.join(path,f) for f in os.listdir(path) if f.endswith('.csv')]
def group_uniqmz_intensities(path):
pxlist = sorted(get_pixelist(path))
gives:
1_00000_6.54.csv
10_00000_1.70.csv
11_00000_1.70
...
2_00000_1.70.csv
...
3_00000_1.70.csv
...
I want the order shown before.