I am trying to solve the following question and can't seem to find what the problem with my code is:
You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n.
For each index i, names[i] and heights[i] denote the name and height of the ith person.
Return names sorted in descending order by the people's heights.
Here is my code
def sortPeople(self, names: List[str], heights: List[int]) -> List[str]:
res=[];
while len(heights)!=0:
res.append(names[heights.index(max(heights))]);
names.remove(names[heights.index(max(heights))])
heights.remove(max(heights));
return res