Zest.

C++: Lambda and std::sort

A short, tested C++ example for lambda and std::sort. Copy it and adjust the names and paths for your project.

C++
std::vector<int> v = {3, 1, 2};
std::sort(v.begin(), v.end(), [](int a, int b) { return a > b; });

auto add = [](int a, int b) { return a + b; };
std::cout << add(2, 3);

Find it in Zest

Search for “cpp lambda and std::sort” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More C++ examples

All C++ examples