MCPcopy Create free account
hub / github.com/apache/nutch / sortByValue

Method sortByValue

src/java/org/apache/nutch/util/Histogram.java:95–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93 }
94
95 public List<E> sortByValue() {
96 List<Map.Entry<E, HistogramEntry>> list = new Vector<Map.Entry<E, HistogramEntry>>(
97 map.entrySet());
98
99 // Sort the list using an annonymous inner class implementing Comparator for
100 // the compare method
101 java.util.Collections.sort(list,
102 new Comparator<Map.Entry<E, HistogramEntry>>() {
103 public int compare(Map.Entry<E, HistogramEntry> entry,
104 Map.Entry<E, HistogramEntry> entry1) {
105 return (entry.getValue().equals(entry1.getValue()) ? 0 : (entry
106 .getValue().value > entry1.getValue().value ? 1 : -1));
107 }
108 });
109 List<E> list2 = new Vector<E>();
110 for (Map.Entry<E, HistogramEntry> entry : list) {
111 list2.add(entry.getKey());
112 }
113 return list2;
114 }
115
116 public String toString(List<E> items) {
117 StringBuilder strBuilder = new StringBuilder();

Callers

nothing calls this directly

Calls 2

getKeyMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected