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

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -