List of usage examples for java.util Arrays sort
public static <T> void sort(T[] a, int fromIndex, int toIndex, Comparator<? super T> c)
From source file:Main.java
public static void main(String[] args) { // initializing unsorted short array Short sArr[] = new Short[] { 3, 13, 1, 9, 21 }; System.out.println(Arrays.toString(sArr)); // create a comparator Comparator<Short> comp = Collections.reverseOrder(); // sorting array with reverse order using comparator from 0 to 2 Arrays.sort(sArr, 0, 2, comp); System.out.println(Arrays.toString(sArr)); }