Know you sorting options: It makes no sense to sort elements in standard
associative containers, because such containers use their comparison
functions to remain sorted all the time.
For other sequence container, sorting options is below: (1-3) need random
iterator. 4 only need bidirection iterator.(list)
full sort on vector, string, deque, or array. use sort or stable_sort
put only the top n elements in order, partial_sort
Identify the elements at position n , you need nth_element
spearate the elements of a standard sequence container, do satisfy
some criterion, you use partition or stable_partition.
for list, you should use list.sort() in place of common sort.
For a algorithms, you need to know three points: 1) what’sfunction for 2) what iterator it accept, 3) what functor it willaccept. So please see below summary.