I have a script whose purpose is to sort and process spatial dataset files which are constantly being downloaded onto a server. My list currently looks roughly like this:
list = ['file.t00Z.wrff02.grib2', 'file.t00Z.wrff03.grib2', 'file.t00Z.wrff00.grib2',
'file.t00Z.wrff05.grib2', 'file.t00Z.wrff04.grib2', 'file.t00Z.wrff01.grib2',
'file.t06Z.wrff01.grib2', 'file.t06Z.wrff00.grib2', 'file.t06Z.wrff02.grib2', ...]
As you can see, each file has a specific naming convention.
Later in the script, the files in this list will be processed sequentially, but I need to process them in order of the time designated by the two digits following "wrff" in each filename (00, 01, 02...).
I currently have a regular expression which removes any files from the list which don't match the two digits following "file.t", as is necessary. But is there an easy method to sort list elements by substring?
Note: I would choose to simply sort these files by modification time, but they often appear in the data directory out of order.