Everything

qsort


Performs sorting.

[Format]

// C

#include <stdlib.h>

void qsort (const void *base, size_t nmemb, size_t size, long (*compar)(const void *, const void *));

 

// C++/EC++

#include <stdlib.h>

void qsort(const void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));

[Parameters]

base Pointer to the table to be sorted

nmemb Number of members to sort

size Number of bytes of a member to be sorted

compar Pointer to a function to perform comparison

[Remarks]

The qsort function sorts out data on the table pointed to by base. The data arrangement order is specified by the pointer to a function to perform comparison. This comparison function should receive pointers p1 (first parameter) and p2 (second parameter) as two data items to be compared, and return the result complying with the specification below.

*p1 < *p2: Returns a negative value.

*p1 == *p2: Returns 0.

*p1 > *p2: Returns a positive value.