Using qsort
The standard library sort.
The Standard Library Sort
C's standard library provides qsort in <stdlib.h>. It sorts any array given a comparison function, so you rarely need to write your own sort.
The qsort Signature
The prototype is:
basepointer to the first elementnmembnumber of elementssizebytes per elementcompara comparison function pointer
void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
All lessons in this course
- Bubble and Insertion Sort
- Quicksort
- Mergesort
- Using qsort