Sorting is rearranging the given data in a specific format- ascending or descending.
The purpose of sorting elements is to greatly improve the efficiency of searching while doing computations on the data.
In Java, we can sort primitive data (using sorting algorithms) , or user-defined data (using Comparable or Comparator interfaces)
We have 2 main kinds of sorting:
1. Internal Sorting - done in main memory
2. External Sorting - algorithms that use external memory like tape, or a disk for sorting.
External sorting is used when data is too large to fit into main memory.