你的思路有问题:
1.要二分查找,必须是有序的
2.要排序,必须有排序规则:Comparable或者Comparator
参考文章:
http://blog.csdn.net/treeroot/archive/2004/10/19/142636.aspx
http://blog.csdn.net/treeroot/archive/2004/10/11/132732.aspx
1.要二分查找,必须是有序的
2.要排序,必须有排序规则:Comparable或者Comparator
参考文章:
http://blog.csdn.net/treeroot/archive/2004/10/19/142636.aspx
http://blog.csdn.net/treeroot/archive/2004/10/11/132732.aspx
Sorts the specified array of objects into ascending order, according to the natural ordering of its elements. All elements in the array must implement the Comparable interface. Furthermore, all elements in the array must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the array).
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist). This algorithm offers guaranteed n*log(n) performance.
Parameters:
a - the array to be sorted.
Throws:
ClassCastException - if the array contains elements that are not mutually comparable (for example, strings and integers).