Arrays.sort() in java
// java program to sort strings in an alphabetical order
import java.util.Arrays;
public class SortStringAlphabeticalOrder
{
public static void main(String[] args)
{
String[] strAsc = {"Bear","Fox","Deer","Cheetah","Anteater","Elephant"};
System.out.println("Before sorting: ");
for(String string : strAsc)
{
System.out.println(string);
}
// arrays.sort
Arrays.sort(strAsc);
System.out.println("-----------------------------------");
System.out.println("After sorting: ");
for(String str : strAsc)
{
System.out.println(str);
}
}
}