Sunday, May 15, 2011

Collections.sort() vs Arrays.sort()

Difference between the Collections.sort() and Arrays.sort()?

Difference between the two is input. Collections.sort() has a input as List so it does a translation of List to array and vice versa which is an additional step while sorting. So this should be used when you are trying to sort a list. Arrays.sort is for arrays so the sorting is done directly on the array. So clearly it should be used when you have a array available with you and you want to sort it.

Algorithm – Algorithm seems to be same.

No comments:

Post a Comment