Originally Posted by
cyberfish
then, do it as you would on the array, but swap the elements in both arrays where you would have swapped one
Code:
void lsort(int &n, int val[], double gp[]){
int temp,temp1;
for(int pass = 0; pass < n - 1; pass++)
for(int cand = pass + 1; cand < n; cand++)
if(val[pass] > val[cand]){
temp=val[pass];
val[pass]=val[cand];
gp[pass]=gp[cand];
val[cand]=temp;
gp[pass]=gp[cand];
}
return;
}
yeah thats what i did but when i print the new array, in the output i get this::
ID GPA
123 1.9
124 1.9
225 1.1
632 3.2
THE ID GOES IN ORDER BUT THE 124 ID, gets the 123 id for some reason?
THE INPUT FROM FILE IS THIS
4
124 2.6
123 1.9
225 1.1
632 3.2