Jan 28, 2014 at 6:36am
Which type of STL container is used for automatic sorting?
Jan 28, 2014 at 6:56am
What is "automatic sorting"?
Jan 28, 2014 at 7:01am
Means which container we use for the purpose of sorting?
Jan 28, 2014 at 7:50am
Do you mean which containers sort implicitly? Like a set or multiset?
http://www.cplusplus.com/reference/set/set/
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
#include <set>
int main( int argc, const char* argv[] )
{
std::set<int> my_set;
for( int i = 10; i > 0; --i )
my_set.insert( i );
for( const auto &j : my_set )
std::cout << j << " ";
return 0;
}
|
1 2 3 4 5 6 7 8 9 10 |
Last edited on Jan 28, 2014 at 7:54am
Jan 28, 2014 at 7:53am
AFAIK, there is non.
But you can use std::sort() from <algorithm> ??
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
#include <algorithm>
#include <array>
int main()
{
std::array<int, 8> arr { 23, 353, 64, 876, 44, 99, 100, 34 };
std::cout << "Unsorted: ";
for( auto& i : arr ) { std::cout << i << " "; }
std::sort( arr.begin(), arr.end() );
std::cout << "\nSorted: ";
for( auto& i : arr ) { std::cout << i << " "; }
}
|
Last edited on Jan 28, 2014 at 9:19am