import
java.util.Arrays;
import java.util.Comparator;
public class CharArraySort {
public static void main(String[] args) {
String[] str = { " a " , " b " , " B " , " d " , " D " , " K " , " j " , " n " , " N " , " s " };
Arrays.sort(str, 0 ,str.length, new Comparator < String > ()
{
public int compare(String str1, String str2) {
String temp1 = str1.toLowerCase();
String temp2 = str2.toLowerCase();
if ( ! temp1.equals(temp2))
return temp1.compareTo(temp2);
else
return str1.compareTo(str2);
}
});
for ( int i = 0 ;i < str.length;i ++ )
System.out.print(str[i] + " " );
}
}
import java.util.Comparator;
public class CharArraySort {
public static void main(String[] args) {
String[] str = { " a " , " b " , " B " , " d " , " D " , " K " , " j " , " n " , " N " , " s " };
Arrays.sort(str, 0 ,str.length, new Comparator < String > ()
{
public int compare(String str1, String str2) {
String temp1 = str1.toLowerCase();
String temp2 = str2.toLowerCase();
if ( ! temp1.equals(temp2))
return temp1.compareTo(temp2);
else
return str1.compareTo(str2);
}
});
for ( int i = 0 ;i < str.length;i ++ )
System.out.print(str[i] + " " );
}
}