githubEdit

Lec 02 - Sorting

Default Sorting

In Java, the sorting is implemented in

  1. Collectionsarrow-up-right (Use Collections.sort(List) to sort a List)

  2. Arraysarrow-up-right (Use Arrays.sort(array) to sort an array, like int[])

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()arrow-up-right, after that the array will be sorted ascending order, according to the natural order of its elements.

Last updated