qsort is quicksort function in linux or Unix. The function prototype is
|
|
maybe I write too many const here:) I will write some examples to sort numbers below:
|
|
qsort function will change the content of array. If you want use complex object in qsort. You should just convert const void to object. If you will use point in array, you should compare with objects use tmp_a-tmp_b. If you want to compare double or float type, you should have a look at my another article: compare double numbers in c/c++ language.
If you want a stable compare function, you can use qsort also. First you should construct a class or struct, then and index or other information into struct. And compare when two values are equal.
|
|