| 1923 | /// when an element in the List does not implement Comparable or |
| 1924 | /// elements cannot be compared to each other. |
| 1925 | @SuppressWarnings("unchecked") |
| 1926 | public static <T extends java.lang.Comparable<? super T>> void sort(List<T> list) { |
| 1927 | Object[] array = list.toArray(); |
| 1928 | Arrays.sort(array); |
| 1929 | int i = 0; |
| 1930 | ListIterator<T> it = list.listIterator(); |
| 1931 | while (it.hasNext()) { |
| 1932 | it.next(); |
| 1933 | it.set((T) array[i++]); |
| 1934 | } |
| 1935 | } |
| 1936 | |
| 1937 | /// Sorts the specified list using the specified comparator. The algorithm is |
| 1938 | /// stable which means equal elements don't get reordered. |