```
class Solution {
public:
static bool myComp(const pair<int, int> &a, const pair<int, int> &b)
{
if (a.first == b.first)
return a.second < b.second;
return a.first > b.first;
}
vector<pair<int, int>> reconstructQueue(vector<pair<int, int>>& people) {
vector<pair<int, int>> ret;
int n = people.size();
if (n == 0)
return ret;
sort(people.begin(), people.end(), myComp);
for (int i = 0; i < n; i++)
{
ret.insert(ret.begin() + people[i].second, people[i]);
}
return ret;
}
};
```