I have a 2D array that I need bubble sorted according to the last column, and I can't seem to get it right. Here's what i have so far:
Why is this not working?
Code:
int bubble(int twoarray[][4], int limit){
int temp[4], index;
for (;limit>0;limit--){
for (index=0;index<limit;index++){
for (int i =0;i<4;i++ ){
if (twoarray[index][3]>twoarray[index+1][3]){
for (i=0;i<4;i++){
temp[i]=twoarray[index][i];
}
for (i=0;i<4;i++){
twoarray[index+1][i]=twoarray[index][i];
}
for (i=0;i<4;i++){
twoarray[index+1][i]=temp[i];
}
Why is this not working?