Commits

Stepan Koltsov  committed c48644d

Tuple2List.sortBy2

  • Participants
  • Parent commits 5756420

Comments (0)

Files changed (1)

File src/main/java/ru/yandex/bolts/collection/Tuple2List.java

         return new Tuple2List<K, V>(sort(get1F().andThen((Function2I<K, K>) comparator)));
     }
 
+    /**
+     * @see CollectionF#sort()
+     */
+    public Tuple2List<K, V> sortBy2() {
+        return sortBy2(Comparator.naturalComparator().<K, K>uncheckedCast());
+    }
+
+    /**
+     * @see CollectionF#sort(Function2I)
+     */
+    @SuppressWarnings("unchecked")
+    public Tuple2List<K, V> sortBy2(Function2I<? super K, ? super K> comparator) {
+        if (size() <= 1) return this;
+        return new Tuple2List<K, V>(sort(get1F().andThen((Function2I<K, K>) comparator)));
+    }
+
+
     // XXX: sortByKeyBy, sortByKeyByDesc
 
     public MapF<K, V> toMap() {