class Solution {
public:
vector<vector<int>> reconstructQueue(vector<vector<int>>& people) {
sort(people.begin(), people.end(), [](vector<int>& lhs, vector<int>& rhs) {
if (lhs[0] != rhs[0]) return lhs[0] > rhs[0];
else return lhs[1] < rhs[1];
});
vector<vector<int>> res;
for (int i = 0; i < people.size(); i++) {
res.insert(res.begin() + people[i][1], people[i]);
}
return res;
}
};