Start of sorting.
Implemented sort routines.