I can not understand the method implementation and the logic of Collections.sort method. Here is the method implementation i found,
public static
The way Collections.sort
works is that it actually takes the collection's underlying array, and calls its sort method to sort the actual elements. That sorting algorithm used by Java is the lightning-fast Timsort.
The method returns void
because it sorts the collection in-place. That is, it modifies the collection you give it as a parameter by sorting its elements. Returning a sorted copy would be a waste of resources.