Originally Posted by
Adak
Try something like this. It sorts according to totals now, but you can change it to any records.member you want.
Code:
void Sorter(void) {
int i, j, gar; //these are just used for counting, nothing fancy
Record *ptr1;
Record *ptr2;
Record *ptrtemp;
for(i = 0; i < 10-1; i++) {
for(j = i+1; j < 10; j++) {
ptr1 = &records[i];
ptr2 = &records[j];
if(ptr1->total < ptr2->total) {
*ptrtemp = *ptr1;
*ptr1 = *ptr2;
*ptr2 = *ptrtemp;
gar++;
}
}
}
}
i want to short by matrix number.. so i just change the part
i
Code:
f(ptr1->total < ptr2->total) {
*ptrtemp = *ptr1;
*ptr1 = *ptr2;
*ptr2 = *ptrtemp;
gar++;
}
to
i
Code:
f(ptr1->matrix <ptr2 ->matrix {
strcpy(*ptrtemp, *ptr1);
strcpy(*ptr1, *ptr2);
strcpy(*ptr2, *ptrtemp);
gar++;
}