All pastes #259196 Raw Edit

Miscellany

public text v1 · immutable
#259196 ·published 2006-11-27 05:32 UTC
rendered paste body
// sorts high to low
void selection_sort(int list[], int n) {
  int i, j, max, temp;

  for(i = 0; i < n; i++) {
    max = i;
    for(j = i + 1; j < n; j++) {
      if(list[max] < list[j]) {
        max = j;
      }
      temp = list[i];
      list[i] = list[max];
      list[max] = temp;
    }
  }
}