DIPlib Documentation - ©1995-2013 Quantitative Imaging Group, Delft University of Technology.

# General information about sorting

There are two kinds of sorting routines in DIPlib. The first sorts a one-dimensional array of data, the second sorts a set of indices to a one-dimensional array of data. The result of the sort routines can be summarised as follows:

Sort: `data[ i ] <= data[ i + 1 ]`

Sort indices: `data[ indices[ i ] ] <= data[ indices[ i + 1 ] ]`

Note that the number of indices does not have to be equal to the amount of pixels in the image, it may be either smaller or larger. The indices themselves should of course "point" to a valid pixel.

The sorting algorithms are described in the following reference:

Donald E. Knuth, "The Art of Computer Programming, volume 3: Sorting and Searching", second edition, Addison-Wesley, 1998.