void MavenFunctions::sortFunctions() {
	int i, j, flag = 1;    // set flag to 1 to start first pass
	int numLength = funcs.size(); 
	for(i = 1; (i <= numLength) && flag; ++i) {
		flag = 0;
		for(j = 0; j < (numLength - 1); ++j) {
			if(strcmp(funcs[j + 1].name.c_str(), funcs[j].name.c_str()) < 0) {
				swapFunction(j, j + 1);
				flag = 1;               // indicates that a swap occurred.
			}
		}
	}
}
Esempio n. 2
0
void
selectionsort (struct frecuencia arr[]) {
  int d,c;
  int position;
  int swap;
  for (c=0; c < TAMANO-1; c++) {
    position = c;
    for (d = c+1; d< TAMANO; d++) {
      if (arr[d].repeticion > arr[position].repeticion) {
	position = d;
      }//end if
    }
    if (position != c) {
       swapFunction(arr, c, position);
      /*swap = arr[c].repeticion;
      arr[c].repeticion = arr[position].repeticion;
      arr[position].repeticion = swap;*/
    }
  }
}