About Sort () in std :: List
List :: sort
Void Sort (); Template
These two member functions are sorted in the predicates described below. It is assumed that the iterator PI points to the elements located at position I, PJ points to the elements at position J, when i #include Std :: List For (i = 9; i> -1; i -) {mystruct.nstart = i; mystruct.nend = 9-i; mystructlist.push_back (mystruct);} Std :: List MYList.Sort (); Printf ("/ NMYLIST: / N"); for (NItem = mylist.begin (); NITEM! = mylist.end (); NITEM ) {Printf ("% D / T", (* nitem)); Std :: List Return 0;} The result is: sort MYLIST Sort: 9 8 7 6 5 4 3 2 1 0 MYLIST Sort by: 0 1 2 3 4 5 6 7 8 9 MyStructList before sort: nStart = 9 nStart = 8 nStart = 7 nStart = 6 nStart = 5nStart = 4 nStart = 3 nStart = 2 nStart = 1 nStart = 0 MyStructList is sorted by member NStart: nStart = 0 nStart = 1 nStart = 2 nStart = 3 nStart = 4NStart = 5 nStart = 6 nStart = 7 nStart = 8 nStart = 9 strunt; int Nend; Bool Operator <(mystruct item) / * Note overload <* / {if (nStart