Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #comparator #anonymous #function
ADD COMMENT
Topic
Name
7+3 =