Skip to content

Instantly share code, notes, and snippets.

@akerenyi
Created February 2, 2015 11:57
Show Gist options
  • Save akerenyi/ea8332b5398d1f9692bb to your computer and use it in GitHub Desktop.
Save akerenyi/ea8332b5398d1f9692bb to your computer and use it in GitHub Desktop.
Quick sort in C
#include <stdio.h>
#include <stdlib.h>
#define SIZE 10
// function needed for quick sort
int compare(const void *a, const void *b);
int main() {
int numbers[SIZE];
/* Sort the array */
qsort(numbers,SIZE,sizeof(int),compare);
return(0);
}
int compare(const void *a, const void *b) {
return( *(int *)a - *(int *)b );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment