Browse - Programming Tips - Is there a sorted list in the Standard Template Library?
Q. Is there a sorted list in the Standard Template Library?
A. No. There are some options.
1. Usually the best way is to use std::set()
It promises to keep everything in order.
Call myset.insert() to add stuff and iterate starting with myset.begin()
2. You can just do a sort() after each push_back()
This is fine for very small lists.
3. You can use sorted_vector<>