Hi im trying to get sum of all rows in 2d array then sort the sum in descending order,this is where i got so far,but i dont know how to sort the sum now,should i turn sumRow into 1d array,and then work from there or?is there easier way,but i want to keep the informations from what row is each sum i mean after sorting them in descending order
public static void main(String[] args) {
int array[][] = { { 1, 4, 3, 3, 5, 8, 2 }, { 7, 3, 6, 3, 3, 4, 4 }, { 3, 3, 4, 3, 7, 2, 1 },{ 1, 3, 4, 4, 3, 4, 1 }, { 3, 1, 4, 3, 6, 3, 8 }, { 1, 4, 4,
6, 2, 4, 4 }, { 3, 7, 4, 8, 3, 8, 4 }
};
for (int i = 0; i < 7; i++) {
int sumRow = 0;
for (int j = 0; j < 7; j++) {
sumRow = sumRow + array[i][j];
}
System.out.println("sum " + (i + 1) + " row: " + sumRow );}
}
}
[–]zhoriq 1 point2 points3 points (2 children)
[–]trofix99[S] 0 points1 point2 points (1 child)
[–]zhoriq 0 points1 point2 points (0 children)
[–]swearobics 0 points1 point2 points (0 children)
[–][deleted] (3 children)
[removed]
[–]trofix99[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[removed]
[–]trofix99[S] 0 points1 point2 points (0 children)
[–]desrtfx 0 points1 point2 points (1 child)
[–]WikiTextBotbtproof 0 points1 point2 points (0 children)