Reorder Data in Log Files
A medium-tier problem at 57% community acceptance, tagged with Array, String, Sorting. Reported in interviews at Snap and 0 others.
Reorder Data in Log Files is a medium-difficulty string and sorting problem that looks trivial on the surface but punishes candidates who skip reading the spec carefully. Snap has asked this repeatedly. The trap is thinking you understand the sorting rules from a quick scan, then realizing mid-solution that the edge cases around numeric logs, tie-breaking, and maintaining insertion order are way more finicky than you expected. About 57% of submissions pass, which tells you most people get partway there and miss something. If this hits your live OA and you blank on the secondary sort rules, StealthCoder surfaces a working solution invisibly, no proctor visibility.
Companies that ask "Reorder Data in Log Files"
Reorder Data in Log Files is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe problem requires you to split logs into two categories (letter-logs and digit-logs), sort letter-logs by content then identifier, preserve digit-logs in their original order at the end, and return the reordered list. The core trick is recognizing that you're not doing a simple sort; you're doing a stable, conditional sort with multiple fallback rules. Most candidates nail the first level (alphabetize by log content) but botch the tie-breaker (sort by identifier lexicographically) or forget that digit-logs must stay untouched. The sorting comparison needs to handle cases where two logs have identical content but different identifiers, or where a log is purely numeric. Writing the comparator wrong is the number-one failure mode. StealthCoder is your safety net if the comparator logic trips you up during the live assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Reorder Data in Log Files recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Reorder Data in Log Files interview FAQ
Is this still asked at FAANG and tech companies?+
Snap has confirmed asking it. The problem appears in mid-level OA rounds where sorting and string manipulation matter. It's not as common as two-pointer problems, but common enough that you should know the pattern. The 57% pass rate means it's a legitimate screening tool.
What's the trick that makes it hard?+
The trick is the multi-level sort: you must partition first (letter vs. digit), then apply a custom comparator to letter-logs only. The comparator itself has two levels (content, then identifier). Many candidates forget the content comparison is lexicographic, not numeric, or they fail to preserve digit-log order. It's fiddly, not algorithmic-hard.
Do I need to optimize for time or space?+
No exotic constraints. Standard sorting (O(n log n) time, O(1) to O(n) space depending on language) is fine. The challenge is correctness of the comparator, not performance. Focus on getting the sort rules right first.
How does this relate to the Array and String topics?+
It combines array manipulation (partitioning, reordering), string parsing (extracting identifier and content from each log), and a custom sort. You'll parse strings, compare them lexicographically, and rebuild the array. All three topics matter equally.
What's the most common mistake?+
Forgetting that digit-logs must stay in their original relative order (stable sort behavior for that partition), or writing the comparator to sort digit-logs when you should ignore them entirely. Also common: comparing identifiers when content is equal, but using the wrong string comparison order.
Want the actual problem statement? View "Reorder Data in Log Files" on LeetCode →