Here you can find the source of sortArray(int[] a)
public static int[] sortArray(int[] a)
//package com.java2s; //License from project: Open Source License public class Main { public static int[] sortArray(int[] a) { int[] b = a.clone(); int t = 0; for (int i = 0; i < a.length; i++) { for (int j = i; j < a.length; j++) { if (b[i] > b[j]) { t = b[i];//w w w . ja v a 2s . co m b[i] = b[j]; b[j] = t; } } } return b; } public static double[] sortArray(double[] a, int[] index) { double[] b = a.clone(); for (int i = 0; i < a.length; i++) { b[i] = a[index[i]]; } return b; } public static double[] clone(double[] p) { double[] ret = new double[p.length]; System.arraycopy(p, 0, ret, 0, p.length); return ret; } public static float[] clone(float[] p) { float[] ret = new float[p.length]; System.arraycopy(p, 0, ret, 0, p.length); return ret; } public static int[] clone(int[] p) { int[] ret = new int[p.length]; System.arraycopy(p, 0, ret, 0, p.length); return ret; } public static byte[] clone(byte[] p) { byte[] ret = new byte[p.length]; System.arraycopy(p, 0, ret, 0, p.length); return ret; } public static char[] clone(char[] p) { char[] ret = new char[p.length]; System.arraycopy(p, 0, ret, 0, p.length); return ret; } public static long[] clone(long[] p) { long[] ret = new long[p.length]; System.arraycopy(p, 0, ret, 0, p.length); return ret; } public static short[] clone(short[] p) { short[] ret = new short[p.length]; System.arraycopy(p, 0, ret, 0, p.length); return ret; } public static String[] clone(String[] p) { String[] ret = new String[p.length]; System.arraycopy(p, 0, ret, 0, p.length); return ret; } public static boolean[] clone(boolean[] p) { boolean[] ret = new boolean[p.length]; System.arraycopy(p, 0, ret, 0, p.length); return ret; } public static double[][] clone(double[][] p) { double[][] ret = new double[p.length][p[0].length]; int nr = p.length; for (int i = 0; i < nr; i++) { System.arraycopy(p[i], 0, ret[i], 0, p[0].length); } return ret; } public static float[][] clone(float[][] p) { float[][] ret = new float[p.length][p[0].length]; int nr = p.length; for (int i = 0; i < nr; i++) { System.arraycopy(p[i], 0, ret[i], 0, p[0].length); } return ret; } public static int[][] clone(int[][] p) { int[][] ret = new int[p.length][p[0].length]; int nr = p.length; for (int i = 0; i < nr; i++) { System.arraycopy(p[i], 0, ret[i], 0, p[0].length); } return ret; } public static long[][] clone(long[][] p) { long[][] ret = new long[p.length][p[0].length]; int nr = p.length; for (int i = 0; i < nr; i++) { System.arraycopy(p[i], 0, ret[i], 0, p[0].length); } return ret; } public static short[][] clone(short[][] p) { short[][] ret = new short[p.length][p[0].length]; int nr = p.length; for (int i = 0; i < nr; i++) { System.arraycopy(p[i], 0, ret[i], 0, p[0].length); } return ret; } public static byte[][] clone(byte[][] p) { byte[][] ret = new byte[p.length][p[0].length]; int nr = p.length; for (int i = 0; i < nr; i++) { System.arraycopy(p[i], 0, ret[i], 0, p[0].length); } return ret; } public static boolean[][] clone(boolean[][] p) { boolean[][] ret = new boolean[p.length][p[0].length]; int nr = p.length; for (int i = 0; i < nr; i++) { System.arraycopy(p[i], 0, ret[i], 0, p[0].length); } return ret; } public static String[][] clone(String[][] p) { String[][] ret = new String[p.length][p[0].length]; int nr = p.length; for (int i = 0; i < nr; i++) { System.arraycopy(p[i], 0, ret[i], 0, p[0].length); } return ret; } }