java - Sorting arrays descending -
i've learned how sort arrays in ascending order code in java;
int swapindex,temp; for(int index=0; index<=array.length-2; index++) { swapindex = index; for(int i=index+1; i<=array.length-1; i++) if(array[i]<array[swapindex]) swapindex = i; temp = array[index]; array[index] = array[swapindex]; array[swapindex] = temp; } }
can please tell me how can use code sort in descending order? best regards
why don't use instead?
arrays.sort(array, collections.reverseorder());
Comments
Post a Comment