partition() subroutine does partial sorting. This should be less work than normal sorting.
Refer to http://en.wikipedia.org/wiki/Partial_sorting for more information. A useful scenario is selecting the top five (or some other number) items of a group. Partial sorting doesn't preserve the right order within the set of the top elements.
The first parameter of the subroutine is the input array to sort. The second parameter is an integer or a list of integers corresponding to the indices of the array elements. The
partition() subroutine sorts items at those indices correctly. One specified index gives two partitions. Multiple indices result in more than two partitions. ...