Hopper·Software Engineer·Technical Phone Screen
- Given a list of filename strings, implement a custom sort using a comparator that handles digit runs numerically, prioritizes digits over non-digits at the first differing position, and uses standard lexicographic order for non-digit parts.
- How should filenames like 'file01.txt' and 'file1.txt' be ordered when their numeric values are equal due to leading zeros, and how would you implement your chosen tie-break?
- If you need to sort a very large number of filenames, how would you optimize the approach to avoid repeatedly parsing digit runs inside the comparator?
“I thought I had this pretty quickly and started writing a comparator right away.”