My program reads in the number parsed from the file name. I want it to be ordered exactly how it is, but, in this example, list as 500, 4000, 7000. How should my naming convention look to achieve this? That is, when I have incrementing numbers, it lists it from smallest to highest.
What I really want is for it to sort by rank, (which here starts at zero), then sorts it by the incrementing numbers.. 500, 5000, 7000.
DESIRED OUTPUT
LOG-rank-0-die-10-delay-500.txt
LOG-rank-0-die-10-delay-4000.txt
LOG-rank-0-die-10-delay-7000.txt
LOG-rank-1-die-10-delay-500.txt
LOG-rank-1-die-10-delay-4000.txt
LOG-rank-1-die-10-delay-7000.txt
LOG-rank-2-die-10-delay-500.txt
LOG-rank-2-die-10-delay-4000.txt
LOG-rank-2-die-10-delay-7000.txt
Relevant Code
for filenamelogs in sorted(os.listdir(log_directory)):
for each_line in filenamelogs:
#various file parsing activity
I'm appending the data file-by-file to various arrays. Unfortunately, this is terrible to me if I can't sort the file reads in the order requested. Maybe my question is veered toward developing a custom method to read in files under the sorting constraints I provide.