Search
 
SCRIPT & CODE EXAMPLE
 

CPP

sort using comparator anonymous function c++

sort(mMyClassVector.begin(), mMyClassVector.end(), 
    [](const MyClass & a, const MyClass & b) -> bool
{ 
    return a.mProperty > b.mProperty; 
});
Comment

sort using comparator anonymous function c++

#include<array>
#include<functional>

int main()
{
    std::array<int, 10> vec = { 1,2,3,4,5,6,7,8,9 };

    std::sort(std::begin(vec), 
              std::end(vec), 
              [](int a, int b) {return a > b; });

    for (auto item : vec)
      std::cout << item << " ";

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: solve diamond inheritance c++ 
Cpp :: assign array to array 
Cpp :: C++ Single Line Comments 
Cpp :: c++ insertion in astack 
Cpp :: set(W) 
Cpp :: empty 2d array as a member of a class class c++ 
Cpp :: c++ sort cout end 
Cpp :: initialize object as null in c++ 
Cpp :: C++ Creating a Class Template Object 
Cpp :: c++ Unable to get CMake Tutorial example to compile 
Cpp :: escribir texto c++ 
Cpp :: __aeabi_assert() 
Cpp :: To toggle (flip the status of) the k-th item of the set 
Cpp :: how to user input in string to open files in c++ 
Cpp :: xor in c++ 
Cpp :: an array that take different data type c++ 
Cpp :: 378. Kth Smallest Element in a Sorted Matrix using binary search 
Cpp :: c++ starting syntaz 
Cpp :: pycuda install failed microsoft c++ 
Cpp :: https://www.geeksforgeeks.org/a-program-to-check-if-strings-are-rotations-of-each-other/ 
Cpp :: cpp console progressbar 
Cpp :: displaying m images one window opencv c++ 
Cpp :: constant qualifier c++ "error display" 
Cpp :: how to input a file path in c++ 
Cpp :: c++ else 
Cpp :: Chef and Feedback codechef solution in cpp 
Cpp :: if c++ 
Cpp :: how to code a segment tree in c++ 
Cpp :: c++ for 
Cpp :: pointer to constant 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =