-
Bug
-
Resolution: Fixed
-
P2
-
8, 9
-
b02
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8045483 | 8u25 | Paul Sandoz | P2 | Resolved | Fixed | b01 |
JDK-8032636 | 8u20 | Paul Sandoz | P1 | Closed | Fixed | b01 |
JDK-8053723 | emb-8u26 | Paul Sandoz | P2 | Resolved | Fixed | b17 |
The implementation of the method Collections.sort(List l, Comparator) should be implemented as follows:
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T> void sort(List<T> list, Comparator<? super T> c) {
list.sort(c);
}
and the default implementation in List.sort should be the previous implementation of Collectors.sort:
default void sort(Comparator<? super E> c) {
Object[] a = toArray();
Arrays.sort(a, (Comparator)c);
ListIterator<E> i = listIterator();
for (Object e : a) {
i.next();
i.set((E) e);
}
}
Thus ensuring that Collection.sort will use the most optimal sort implementation provided by the list implementation.
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T> void sort(List<T> list, Comparator<? super T> c) {
list.sort(c);
}
and the default implementation in List.sort should be the previous implementation of Collectors.sort:
default void sort(Comparator<? super E> c) {
Object[] a = toArray();
Arrays.sort(a, (Comparator)c);
ListIterator<E> i = listIterator();
for (Object e : a) {
i.next();
i.set((E) e);
}
}
Thus ensuring that Collection.sort will use the most optimal sort implementation provided by the list implementation.
- backported by
-
JDK-8045483 Collections.sort(List l, Comparator) should defer to List.sort(Comparator )
- Resolved
-
JDK-8053723 Collections.sort(List l, Comparator) should defer to List.sort(Comparator )
- Resolved
-
JDK-8032636 Collections.sort(List l, Comparator) should defer to List.sort(Comparator )
- Closed