创建了我自己的排序算法,但它不起作用。有什么建议或更简单的方法吗?花了整整一天......这太疯狂了!
2Darray的样本
2342 88 98
3901 75 71
1444 60 855327 95 80
4888 83 100
需要按第二列排序,因此结果如下所示
5327 95 80
2342 88 98
4888 83 100
3901 75 71
1444 60 85for(int row = 0; row < examArray.length-1; row++){
//this checks the second column only. I left is static under column since we only compare that column. for loop will change rows
if(tempArray[row][1]<tempArray[row+1][1]){
//if first final(2nd column) is LESS than 2nd final then I need to swap 1st with second using for loop. Confused here!
for(int i = 0; i < 1; i++){
for(int j = 0; j < examArray[row].length; j++){
//this loads NEW array with new Highest studend and copys the entire row to the first location and so on...
sortedExamArray [i][j] = examArray[row+1][j];
tempArray[i][j] = examArray[i][j];
sortedExamArray[row+1][j]=tempArray[i][j];
tempArray[row+1][j]= examArray[i][j];
tempArray[i][j] = sortedExamArray[i][j];