A Java array is an indexed table with a fixed number of slots, each slot holds a item, and all elements have the same type, this tutorial will demo how to sort an array in Java.

public static void main(String[] args) {
    int[] numberArrays = new int[]{12, 6, 11, 22, 9, 88};
    Arrays.sort(numberArrays);
    for (int i = 0; i < numberArrays.length; i++) {
        System.out.println(numberArrays[i]);
    }

    String[] stringArrays = new String[]{"jamm", "sfse", "sdfsf", "aaaa", "77777"};
    Arrays.sort(stringArrays);
    for (int i = 0; i < stringArrays.length; i++) {
        System.out.println(stringArrays[i]);
    }

    class Att {
        int id;
        String name;

        Att(int id, String name) {
            this.id = id;
            this.name = name;
        }
    }
    Att[] attArrays = new Att[]{new Att(1, "giid"), new Att(3, "2342")};
    class AttComparator implements Comparator<Att> {
    public int compare(Att o1, Att o2) {
        if (o1.id == o2.id) {
            return 0;
        } else if (o1.id > o2.id) {
            return 1;
        } else if (o1.id < o2.id) {
            return -1;
        }
    return 0;
    }
}
Arrays.sort(attArrays, new AttComparator());
for (int i = 0; i < attArrays.length; i++) {
System.out.println(attArrays[i]);
}
}