How to check if all strings in array of strings are in ascending order with C++

1 Answer

0 votes
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    std::vector <std::string> strings = {"c", "c++", "go", "java", "python"};

    std::cout << std::is_sorted( strings.begin(), strings.end(),
                    [](std::string a, std::string b){ return (a < b); });
}




/*
run:

1

*/

 



answered Aug 12, 2023 by avibootz
...