yo/stl/examples/sort.cc
raw| 1 | #include <iostream> |
| 2 | #include <string> |
| 3 | #include <functional> |
| 4 | #include <algorithm> |
| 5 | using namespace std; |
| 6 | |
| 7 | int main(int argc, char **argv) |
| 8 | { |
| 9 | sort(argv, argv + argc, greater_equal<string>()); |
| 10 | |
| 11 | for (int idx = 0; idx < argc; ++idx) |
| 12 | cout << argv[idx] << " "; |
| 13 | cout << '\n'; |
| 14 | |
| 15 | sort(argv, argv + argc, less<string>()); |
| 16 | |
| 17 | for (int idx = 0; idx < argc; ++idx) |
| 18 | cout << argv[idx] << " "; |
| 19 | cout << '\n'; |
| 20 | } |