import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* @author Jignesh Vachhani
*
*/
public class Test
{
/**
* @param args
*/
private List<String> getSortedString()
{
List<String> locales = Arrays.asList("jignesh","vachhani");
Collections.sort(locales, new Comparator<String>()
{
@Override
public int compare(String aO1, String aO2)
{
return aO1.compareTo(aO2);
}
});
return locales;
}
public static void main(String[] args)
{
Test t = new Test();
System.out.println(t.getSortedString());
}
}OutPut :
[jignesh,vachhani]