Skip to content

Instantly share code, notes, and snippets.

@fdovila
Created March 28, 2012 22:09
Show Gist options
  • Save fdovila/2230977 to your computer and use it in GitHub Desktop.
Save fdovila/2230977 to your computer and use it in GitHub Desktop.
Order an array of integers in descending order (c)
// For an array 'a, b, c', with at least 3 elements:
int array[5];
int a, b, c = 0;
for(a = 0; a < 5; a++) {
for(b = a; b < 5; b++) {
if(array[a] > array[b]) {
c = array[a];
array[a] = array[b];
array[b] = c;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment