标签:style class blog code java http
Collections.sort 异常
java.lang.IllegalArgumentException: Comparison method violates its general contract! at java.util.TimSort.mergeHi(TimSort.java:868) at java.util.TimSort.mergeAt(TimSort.java:485) at java.util.TimSort.mergeForceCollapse(TimSort.java:426) at java.util.TimSort.sort(TimSort.java:223) at java.util.TimSort.sort(TimSort.java:173) at java.util.Arrays.sort(Arrays.java:659) at java.util.Collections.sort(Collections.java:217)
Collections.sort(values, new Comparator<Map.Entry<String, Float>>() { <span style="white-space:pre"> </span>public int compare(Map.Entry<String, Float> o1, Map.Entry<String, Float> o2) { <span style="white-space:pre"> </span>return (o2.getValue() > o1.getValue() ? 1 : -1); } });
Collections.sort(values, new Comparator<Map.Entry<String, Float>>() { public int compare(Map.Entry<String, Float> o1, Map.Entry<String, Float> o2) { return o2.getValue().compareTo(o1.getValue()); } });
http://stackoverflow.com/questions/10234038/compare-method-throw-exception-comparison-method-violates-its-general-contract
jdk7 中Collections.sort 异常,布布扣,bubuko.com
标签:style class blog code java http
原文地址:http://blog.csdn.net/fover717/article/details/33730343