[C++]2차원 배열 내장 STL 함수로 SORT하기
2020. 5. 20. 10:42ㆍ프로그래밍
2차원 벡터를 만든뒤 algorithm 헤더에 있는 sort함수를 사용한다.
이때 당연하게 cmp 함수를 커스텀해야 한다.
소스코드
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<vector<int,int>> v;
bool cmp(vector<int> a, vector<int> b)
{
return a[2]>b[2];
}
int main()
{
sort(v.begin(),v.end(),&cmp);
}
'프로그래밍' 카테고리의 다른 글
윈도우 Alt키 <-> Ctrl command 키 위치 변경 - 윈도우 키보드 맥북처럼 사용하기 (6) | 2023.01.28 |
---|---|
[JAVA] call by reference vs call by value (0) | 2021.06.30 |