=====sort===== Syntax: #include void sort(); void sort( BinPred p ); The sort() function is used to sort lists into ascending order. Ordering is done via the < operator, unless p is specified, in which case it is used to determine if an element is less than another. Sorting takes N log N time. Related Topics: [[reverse]] Simple example code: #include #include using namespace std; // Assumes TYPE t; cout << t; is valid. template inline ostream & operator<< ( ostream & theOstream, const list & theList ) { typename list::const_iterator listIterator = theList.begin(); for ( int i = 0; listIterator != theList.end(); ++listIterator, i ++ ) theOstream << " [" << i << "]: \"" << (*listIterator) << "\"" << endl; return theOstream; } struct Functor { bool operator()( const char * a, const char * b ) { return strcmp(a,b) < 0; } }; int main() { list l; /* Load up some example test data... */ char s[3]; s[2] = '\0'; for ( s[0]='c'; s[0]>='a'; s[0]-- ) for ( s[1]='c'; s[1]>='a'; s[1]-- ) l.push_back(strdup(s)); /* Show us that test data... */ cout << l << endl; /* Sort list. */ Functor f; l.sort(f); /* Show us what we have now... */ cout << l << endl; }