Test test test. One simple sorting technique is insertion sort . Insertion sort is the sort Peter sugested. Insertion sort operates by segmenting the list into unsorted and sorted portions, and repeatedly removing the first element from the unsorted portion and inserting it into the correct place in the sorted portion. This may be likened to the way typical card players sort their hands.
Selection sort is among the simpler and more natural methods for sorting vectors.
In this sorting algorithm, you segment the vector into two subparts, a sorted part and an unsorted part. You repeatedly find the largest of the unsorted elements, and swap it into the beginning of the sorted part. This swapping continues until there are no unsorted elements. I'll show examples with a list of numbers. So, let's think again about what we can do if we've sorted the two halves.