Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created November 13, 2019 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/ba151d5fbc0266c1cc4d170083f48c54 to your computer and use it in GitHub Desktop.
Save parzibyte/ba151d5fbc0266c1cc4d170083f48c54 to your computer and use it in GitHub Desktop.
int funcionQueCompara(const void *a, const void *b) {
// Castear a enteros
int aInt = *(int *) a;
int bInt = *(int *) b;
// Al restarlos, se debe obtener un número mayor, menor o igual a 0
// Con esto ordenamos de manera ascendente
return bInt - aInt;
}
qsort(arreglo, longitud, tamanioElemento, funcionQueCompara);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment