String []z={"a","c","f","d"};
        for(int i=0;i<z.length-1;i++){
            for(int j=0;j<z.length-i-1;j++){
                if(z[j+1].hashCode()<z[j].hashCode()){
                    String temp=null;
                    temp=z[j];
                    z[j]=z[j+1];
                    z[j+1]=temp;

                }
            }

        }
        for(int i=0;i<z.length;i++){
            System.out.println(z[i]);
        }
    }
}

结果是:
a
c
d
f
总结:咱们这里只需要用比较hash码就可以