java中字符串數組排序 Arrays.sort() 是按西安大寫後小寫拍的 但是我想講笑a排在B之前
有什麼方法能實現
最好不是新建一個方法
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
class C implements Comparator
{
public int compare(Object arg0, Object arg1)
{
String s1 = arg0.toString().toLowerCase();
String s2 = arg1.toString().toLowerCase();
return s1.compareTo(s2);
}
}
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
String[] a = new String[] { "a", "b", "c", "A", "B", "C" };
Arrays.sort(a, new C());
for (int i = 0; i < a.length; i++)
System.out.println(a[i]);
}
}