Lec 02 - Sorting
Default Sorting
In Java, the sorting is implemented in
Collections (Use
Collections.sort(List)to sort a List)Arrays (Use
Arrays.sort(array)to sort an array, likeint[])
An example which uses this feature to solve a problem is as follows,
Basically, we can create an array using ArrayList and then pass that array as the argument of the Collections.sort(), after that the array will be sorted ascending order, according to the natural order of its elements.
Last updated