- #include <algorithm>
- #include <vector>
- #include <iostream>
- static
- bool comp_string(std::string &a, std::string &b)
- {
- return (std::stoi(a) < std::stoi(b));
- }
- int main(int ac, char *av[])
- {
- std::vector<std::string> v1{ "13", "17", "1", "2", "3", "5", "7", "11" };
- std::sort(v1.begin(), v1.end(), comp_string);
- std::cout << "test results:" << std::endl;
- for (auto x : v1)
- std::cout << x << std::endl;
- return EXIT_SUCCESS;
- }
vector sort demo 001
Posted by Anonymous on Tue 19th Nov 2024 13:24
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
rovema.kpaste.net RSS