我完全不知道如何去解決這個問題,但是我在Java中使用了一個用於AI Pathfinder系統的數組,並且我需要對這些值進行排序。下面是我生成的陣:Java多維數組排序
int[][] paths = new int[Settings.GAME_COLS][Settings.GAME_ROWS]; // Just creating an Array that has room for every tile in the Game, so the Array can be used like this: paths[x][y]
int tempF = 0;
tempF = Math.abs(14 + (((aiX + 1) - playerX) + ((aiY - 1) - playerY)));
paths[aiX + 1][aiY - 1] = tempF;
tempF = Math.abs(14 + (((aiX + 1) - playerX) + ((aiY + 1) - playerY)));
paths[aiX + 1][aiY + 1] = tempF;
tempF = Math.abs(14 + (((aiX - 1) - playerX) + ((aiY + 1) - playerY)));
paths[aiX - 1][aiY + 1] = tempF;
tempF = Math.abs(14 + (((aiX - 1) - playerX) + ((aiY - 1) - playerY)));
paths[aiX - 1][aiY - 1] = tempF;
tempF = Math.abs(10 + (((aiX + 1) - playerX) + (aiY - playerY)));
paths[aiX + 1][aiY ] = tempF;
tempF = Math.abs(10 + (((aiX - 1) - playerX) + (aiY - playerY)));
paths[aiX - 1][aiY ] = tempF;
tempF = Math.abs(10 + ((aiX - playerX) + ((aiY + 1) - playerY)));
paths[aiX ][aiY + 1] = tempF;
tempF = Math.abs(10 + ((aiX - playerX) + ((aiY - 1) - playerY)));
paths[aiX ][aiY - 1] = tempF;
的所有作品,完美地找到並生成所需要的信息的陣列,但我需要根據到陣列添加了「tempF」數值數組進行排序。是否有捷徑可尋?
我把二維排序你可以試試嗎?請,並可以告訴我結果? –