How would you sort filenames with numeric segments?
Company: Hopper
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Overview: This question evaluates a candidate's ability to design custom string comparators, parse maximal digit runs and compare numeric values, and handle edge cases such as leading zeros and digit-versus-non-digit ordering.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: (['file10.txt','file2.txt','10file.txt'],)
Expected Output: ['10file.txt', 'file2.txt', 'file10.txt']
Explanation: Numeric runs and digit-first.
Input: (['file01.txt','file1.txt','file001.txt'],)
Expected Output: ['file1.txt', 'file01.txt', 'file001.txt']
Explanation: Leading-zero tie-break.
Hints
- Model object-style prompts as operation streams when needed.
- Handle empty and boundary cases before the main logic.