Are there any built in functions in C programming language for sorting arrays? Or do I have to write my own functions?
Are there any built in functions in C programming language for sorting arrays? Or
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Check out qsort
Syntax:
#include <stdlib.h>void qsort( void *buf, size_t num, size_t size, int (*compare)(const void *, const void *) );
Description:
The
qsort()function sorts buf (which contains num items, each of size size) using Quicksort. The compare function is used to compare the items in buf. compare should return negative if the first argument is less than the second, zero if they are equal, and positive if the first argument is greater than the second. qsort() sorts buf in ascending order.