Sort the People
A easy-tier problem at 85% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at Infosys and 0 others.
Sort the People is an easy problem that appears deceptively simple but tests your ability to coordinate multiple arrays by a shared index. You're given names and heights, and you need to return the names sorted by height in descending order. Infosys has asked this one. The trap is thinking you need a complex data structure when the real trick is understanding how to pair, sort, and extract in a single pass. If you hit this during your assessment and freeze on the mechanics, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Sort the People"
Sort the People 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 by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.
Get StealthCoderThe naive approach is to create a list of tuples, sort by height, then extract names. That works, but the real pattern is recognizing this as a coordinate-sorting problem: you have two arrays that move together. Sort by the height array while dragging the name array along. The common pitfall is forgetting that sorting happens on one dimension while extraction happens on another. Once you've paired the data (usually a zip operation or array of objects), the sort order is non-negotiable. This is where candidates second-guess themselves on descending vs ascending. StealthCoder handles the implementation detail the moment you're unsure, letting you move on during the live OA.
Pattern tags
You know the problem.
Make sure you actually pass it.
Sort the People recycles across companies for a reason. It's easy-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 by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Sort the People interview FAQ
Is Sort the People still asked at top companies?+
Infosys has reported this problem. It's in the easy tier, so it shows up as a warm-up or second problem in loops. Don't expect it as a hard filter, but don't neglect it either. An easy problem solved confidently signals competence.
What's the actual trick to Sort the People?+
The trick is the pairing mechanism. You need to keep heights and names synchronized. Use a structure (tuple, object, or custom class) that holds both, sort by height, extract names. The descent into a specific implementation language matters less than understanding the coordination.
How does this relate to sorting and hash tables?+
Sorting is the main topic. Hash tables come into play if you choose to invert the mapping (height as key, name as value), but that's overcomplicating it. The direct pairing-and-sort approach is cleaner and sidesteps hash collisions entirely.
Why am I second-guessing the sort order?+
The problem asks for descending height. Read carefully. Candidates often skim and default to ascending. Check the expected output format in the problem statement. One wrong sort order and your solution fails all test cases despite correct logic.
Can I solve this with just Array and String topics, no extra data structures?+
Yes. Most languages allow you to zip arrays, sort by one, and extract the other in a few lines. Python's zip and sorted, Java's stream API, JavaScript's map and sort all work. You don't need a hash table unless you invent unnecessary overhead.
Want the actual problem statement? View "Sort the People" on LeetCode →