In your particular case, the fastest view is probably described in this answer . It is finely optimized for an array of 6 circuits and uses sorting networks. This is 20 times (measured on x86) faster than the qsort library. Sort nets are optimal for sorted arrays with a fixed length. Since they are a fixed sequence of instructions, they can be easily implemented using hardware.
Generally speaking, there are many sorting algorithms optimized for some specialized case. General-purpose algorithms, such as heap sorting or quick sort, are optimized for sorting an array of elements in place. They give complexity O (n.log (n)), n is the number of elements to sort.
The qsort () library function is very well coded and efficient in terms of complexity, but uses a call to some mapping function provided by the user, and this call is quite expensive.
To sort a very large number of data algorithms, you also need to take care of replacing the data on and off the disk, this is the type of sorting implemented in the databases, and your best choice, if you have such needs, to put the data in any database and use inline sorting.
kriss Oct 08 '10 at 20:13 2010-10-08 20:13
source share