in reply to Complex Sorting Optimization?

If $disc_file looks like "CD1\01100809.pdf", and the n in CDn is in 1..9, and the filenames are uniformly 8 digits long, you can turn the initial string comparison into a numeric comparison by concatenating the CD number with the file number for purposes of sorting. For example,   CD1\01100809.pdf becomes   102200809 Numeric comparisons are faster than string comparisons. If the CD number can be larger than 9, zero pad that part as necessary so that it is a uniform width.