Java provides a built-in method Arrays.sort() which can be used to sort arrays of primitive data types as well as arrays of objects.
Sorting Primitive Arrays
For primitive types (e.g., int, char, float), Arrays.sort() uses a Dual-Pivot Quicksort algorithm, which is very efficient for most data sets.
import java.util.Arrays;
New contributor
Shenol Shengov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.