sort using comparator anonymous function c 2b 2b

Solutions on MaxInterview for sort using comparator anonymous function c 2b 2b by the best coders in the world

showing results for - "sort using comparator anonymous function c 2b 2b"
Giorgia
26 Jul 2019
1#include<array>
2#include<functional>
3
4int main()
5{
6    std::array<int, 10> vec = { 1,2,3,4,5,6,7,8,9 };
7
8    std::sort(std::begin(vec), 
9              std::end(vec), 
10              [](int a, int b) {return a > b; });
11
12    for (auto item : vec)
13      std::cout << item << " ";
14
15    return 0;
16}
17
Giulio
15 Jan 2017
1sort(mMyClassVector.begin(), mMyClassVector.end(), 
2    [](const MyClass & a, const MyClass & b) -> bool
3{ 
4    return a.mProperty > b.mProperty; 
5});
6