2502. Sort the People
My accepted Python solution to LeetCode problem 2502, Sort the People, running in 4ms.
- Difficulty: Easy
- Python
- Runtime 4ms
- Memory 17.6MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 4ms, memory 17.6MB, accepted 2026-01-01.
class Solution:
def sortPeople(self, names: List[str], heights: List[int]) -> List[str]:
paired = list(zip(heights, names))
paired.sort(reverse=True)
return [name for height, name in paired]