1 bool cmp(vector<int>& a,vector<int>& b) 2 { 3 //第一个数从大到小排列 如果第一个数相等,则第二个数从小到大排列 4 return a[0] > b[0] || ((a[0] == b[0]) && (a[1] < b[1])); 5 } 6 7 class Solution 8 { 9 public: 10 vector<vector<int>> reconstructQueue(vector<vector<int>>& people) 11 { 12 sort(people.begin(),people.end(),cmp); 13 vector<vector<int>> res; 14 for(auto a : people) res.insert(res.begin() + a[1],a); 15 return res; 16 } 17 };