So I've got some files that look like this .../100keV8cm.txt. This goes from 1-10 cm and 80,100,120 keV. The problem is that when I try to sort them, it places 1-9cm in the correct order for all energies but it places the 10cm one for each energy at the end of the appended list. This is the code I have so far:
for i in range(emin,emax+steps,steps):
for filename in os.listdir(directory):
if f'{i}keV' in filename:
input_files.append(directory + filename)
else:
continue
emin+=steps
input_files.sort(key=lambda f: int(''.join(filter(str.isdigit, f))))
I want it to go 1-10cm for 80keV, then the next 10 files for 100keV and so on.