C++ sort排序二位数组
时间: 2023-08-31 20:11:08 浏览: 144
c++对数组的排序
C++中的sort函数可以用于对一维数组进行排序,对于二维数组,可以通过自定义sort函数来对二维数组的特定维度进行排序。
对于一个二维数组,如果要对其第二个关键字进行排序,可以使用自定义sort函数,如下所示:
```
vector<vector<int>> test; // 二维数组test
sort(test.begin(), test.end(), [](const vector<int>& a, const vector<int>& b){
return a < b<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [c++ sort()函数对二维数组vector排序](https://blog.csdn.net/weixin_44153180/article/details/127867911)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [QT C++学习代码案例](https://download.csdn.net/download/m0_73878864/88259441)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文