GNU Scientific Library Reference Manual - Third Edition (v1.12)by M. Galassi, J. Davies, J. Theiler, B. Gough, G. Jungman, P. Alken, M. Booth, F. Rossi Paperback (6"x9"), 592 pages, 60 figures ISBN 0954612078 RRP £24.95 ($39.95) |

# 11 Sorting

This chapter describes functions for sorting data, both directly and
indirectly (using an index). All the functions use the *heapsort*
algorithm. Heapsort is an O(N \log N) algorithm which operates
in-place and does not require any additional storage. It also provides
consistent performance, the running time for its worst-case (ordered
data) being not significantly longer than the average and best cases.
Note that the heapsort algorithm does not preserve the relative ordering
of equal elements--it is an *unstable* sort. However the resulting
order of equal elements will be consistent across different platforms
when using these functions.

ISBN 0954612078 | GNU Scientific Library Reference Manual - Third Edition (v1.12) | See the print edition |