排序阵列柱像我想在这里做的是我的最后一排我的值进行排序,并根据对其他colums是排序数可能在同一行中也改变排序二维数组3列
例如
int[][] array= { {1, 5, 3},{2, 6, 4},{12, 10, 1},{30, 75, 1} };
和输出应该是
{12, 10, 1} {30, 75, 1} {1, 5, 3} {2, 6, 4}
`System.out.println(“Entre la cantidad de procesos que quiere correr:”); int pros = scan.nextInt();
int[][] myArr = new int[pros][3];
for(int i=0; i< pros; i++){
System.out.println("CPU Burst proceso "+count+" :");
time2=scan.nextInt();
System.out.println("Arrival Time proceso "+count+" :");
arrt=scan.nextInt();
myArr[i][0]=count;
myArr[i][1]=time2;
myArr[i][2]=arrt;
count++;
}
Arrays.sort(myArr, new Comparator<int[]>() {
public int compare(int[] o1, int[] o2) {
return Integer.compare(o2[2], o1[2]);
}
});
System.out.println(Arrays.deepToString(myArr)); `
你能分享你已经尝试到现在什么。你至少需要中途到达,以便我们能够帮助你。 – Panther
我发现,但我试图实施,但没有工作\t \t \t \t \t myArr.sort(function(a,b){return a [2] - b [2]; \t}); –
可以请你帮我分类算法,你想要的。根据你的输入和输出,我不能排除任何逻辑 –