List of usage examples for java.util Arrays sort
public static void sort(Object[] a, int fromIndex, int toIndex)
From source file:MainClass.java
public static void main(String[] a) { int array[] = { 2, 5, -2, 6, -3, 8, 0, -7, -9, 4 }; Arrays.sort(array, 3, 7); for (int i : array) { System.out.println(i);/*from w w w . j a v a 2 s . c om*/ } }
From source file:Main.java
public static void main(String[] args) { byte bArr[] = { 10, 17, 4, 7, 2 }; System.out.println(Arrays.toString(bArr)); // sorting array from index 1 to 4 Arrays.sort(bArr, 1, 4); System.out.println(Arrays.toString(bArr)); }
From source file:Main.java
public static void main(String[] args) { char aArr[] = { 'j', 'a', 'v', 'a' }; System.out.println(Arrays.toString(aArr)); // sorting array from index 0 to 3 Arrays.sort(aArr, 0, 3); System.out.println(Arrays.toString(aArr)); }
From source file:Main.java
public static void main(String[] args) { long lArr[] = { 131, 13, 2, 98, 11 }; System.out.println(Arrays.toString(lArr)); // sorting array from index 1 to 3 Arrays.sort(lArr, 1, 3); System.out.println(Arrays.toString(lArr)); }
From source file:Main.java
public static void main(String[] args) { // initializing unsorted int array int iArr[] = { 13, 11, 112, 18, 10 }; System.out.println(Arrays.toString(iArr)); // sorting array from index 0 to 3 Arrays.sort(iArr, 0, 3); System.out.println(Arrays.toString(iArr)); }
From source file:Main.java
public static void main(String[] args) { // initializing unsorted short array short[] sArr = { 13, 13, 11, 9, 21 }; System.out.println(Arrays.toString(sArr)); // sorting array from index 1 to 4 Arrays.sort(sArr, 1, 4); System.out.println(Arrays.toString(sArr)); }
From source file:Main.java
public static void main(String[] args) { // initializing unsorted Object array Object ob[] = { 27, 11, 5, 44, 22, 0 }; System.out.println(Arrays.toString(ob)); // sorting array from index 1 to 3 Arrays.sort(ob, 1, 3); System.out.println(Arrays.toString(ob)); }
From source file:Main.java
public static void main(String[] args) { // initializing unsorted double array double dArr[] = { 13.1, 1.4, 0.7, 1.5, 0.7 }; System.out.println(Arrays.toString(dArr)); // sorting array from index 0 to 3 Arrays.sort(dArr, 0, 3); System.out.println(Arrays.toString(dArr)); }
From source file:Main.java
public static void main(String[] args) { // initializing unsorted float array float fArr[] = { 13.1f, 1.4f, 0.7f, 1.5f, 8.7f }; System.out.println(Arrays.toString(fArr)); // sorting array from index 0 to 3 Arrays.sort(fArr, 0, 3); System.out.println(Arrays.toString(fArr)); }
From source file:Main.java
@Override protected void compute() { if (serialThresholdMet()) { Arrays.sort(a, left, right + 1); } else {// ww w . j a v a2 s .co m int pivotIndex = partition(a, left, right); ForkJoinQuicksortTask t1 = new ForkJoinQuicksortTask(a, left, pivotIndex - 1); ForkJoinQuicksortTask t2 = new ForkJoinQuicksortTask(a, pivotIndex + 1, right); t1.fork(); t2.compute(); t1.join(); } }