MCPcopy Create free account
hub / github.com/davidgiven/luje / sort

Method sort

lib/java/util/Collections.java:1938–1948  ·  view source on GitHub ↗

Sorts the specified list in ascending natural order. The algorithm is stable which means equal elements don't get reordered. @param list the list to be sorted. @throws ClassCastException when an element in the List does not implement Comparable or elements cannot

(List<T> list)

Source from the content-addressed store, hash-verified

1936 * elements cannot be compared to each other.
1937 */
1938 @SuppressWarnings("unchecked")
1939 public static <T extends Comparable<? super T>> void sort(List<T> list) {
1940 Object[] array = list.toArray();
1941 Arrays.sort(array);
1942 int i = 0;
1943 ListIterator<T> it = list.listIterator();
1944 while (it.hasNext()) {
1945 it.next();
1946 it.set((T) array[i++]);
1947 }
1948 }
1949
1950 /**
1951 * Sorts the specified list using the specified comparator. The algorithm is

Callers

nothing calls this directly

Calls 7

sortMethod · 0.95
toArrayMethod · 0.65
listIteratorMethod · 0.65
hasNextMethod · 0.65
nextMethod · 0.65
setMethod · 0.65
sizeMethod · 0.65

Tested by

no test coverage detected