As a Java programmer, quite often you would need to sort array in Java luckily java.util.Arrays class provides several utility methods to Sort an array in Java. You can sort different types of array in Java like array of primitive data types, object or int, String, etc. Arrays are in java.util package and exposed all sorting related methods as static utility functions. you can access sort() as Arrays.sort() and just pass your array and it will sort that array object by comparing them in the order implemented in the compareTo() method if the class implements Comparable interface. You can also sort arrays in ascending order, descending order, or any custom order defined by the custom comparator in Java.
This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here