#How am i suppose to reverse sort this thing
11 messages · Page 1 of 1 (latest)
Hey, @olive zealot!
Please remember to /close this post once your question has been answered!
I don't think Arrays.sort() offers a way to sort primitive arrays in any order but the natural one.
I won't check all answers. First 3 ones don't work with primitives, as I'm sure you noticed. Did you find one that does?
pretty much
Normally you'd just use the array in reverse order
Again, not with primitives. But I said Arrays.sort() can't let you choose the sort order. But you could do it with a stream
Try and use the array length
Avoid putting the other end as part of the loop's increment/decrement. Deduce j from i
for(int i = 0; i < sorted.length / 2; i++) {
int j = sorted.length - 1 - i;
clearer