Function (Path Standard C Header / stdlib.h)

qsort

void qsort(void *base, int num, int size, sort_comparator comparator);

Sort the given array, use quick sort method


Parameters

  void *base
    Array first pointer

  int num
    The length of the array, the best practice is sizeof(array) / sizeof(elemType)

  int size
    Size of array element, the best practice is sizeof(elemType)

  sort_comparator comparator
    A comparator between two given elements, if the element type is number, the best practice is a - b.

函数 (属于 标准C头文件 / stdlib.h)

qsort

void qsort(void *base, int num, int size, sort_comparator comparator);

对给定的数组进行排序,使用快速排序算法


参数

  void *base
    数组首指针

  int num
    数组长度,最佳实践是sizeof(array) / sizeof(元素类型)

  int size
    数组每项大小,最佳实践是sizeof(元素类型)

  sort_comparator comparator
    两个元素的比较器,若为数字类型则最佳实践可以是a-b