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) -

xcode - Swift Playground - Files are not readable -

jboss7.x - JBoss AS 7.3 vs 7.4 and differences -