How can I sort a List alphabetically?

Lennie picture Lennie · Apr 2, 2009 · Viewed 434.4k times · Source

I have a List<String> object that contains country names. How can I sort this list alphabetically?

Answer

Thilo picture Thilo · Apr 2, 2009

Assuming that those are Strings, use the convenient static method sort

 java.util.Collections.sort(listOfCountryNames)