Selection Sort on a 2D Array

Hello-

I need to do a selection sort on two different 2d arrays, sorting by the last column of one of them (thirdarray). The first column of thirdarray is the effective column size for the first (morearray) array. I am so confused. I cant find any examples to help me. Here is what I have so far:

Code:

`int selectionsort(int morearray[][5], int thirdarray[][3],int total){`

int temp[5], index_of_largest;

for ( ;total>0;total--){

index_of_largest=0;

for (int index=1;index<=total;index++){

if (thirdarray[index][2]>thirdarray[index+1][2]){

index_of_largest=index;

}

if (total!=index_of_largest){

for (int f=0;f<thirdarray[index][0];f++){

temp[index]=morearray[index][total];

morearray[index][total]=morearray[index][index_of_largest];

morearray[index][index_of_largest]=temp[index];

}

}

}

}

return(twoarray[total][4]);

return(morearray[total][5]);