How to sort a vector of strings in angle brackets with C++

1 Answer

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

int main()
{
    std::vector<std::string> vec = {"<string>", "<iostream>", "<ostream>", "<numbers>", "<algorithm>"};
 
    std::sort(vec.begin(), vec.end());
    
    for (auto str: vec) {
        std::cout << str << "\n";
    }
}

 
 
/*
run:
 
<algorithm>
<iostream>
<numbers>
<ostream>
<string>
 
*/

 



answered Jul 27, 2024 by avibootz
...