public static < E extends Comparable < ? super E > > ImmutableList < E > sortedCopyOf ( Iterable < ? extends E > elements ) { Comparable < ? > [ ] array = Iterables . toArray ( elements , new Comparable < ? > [ 0 ] ) ; checkElementsNotNull ( ( Object [ ] ) array ) ; Arrays . sort ( array ) ; return asImmutableList ( array ) ; }
Returns an immutable list containing the given elements sorted according to their natural order . The sorting algorithm used is stable so elements that compare as equal will stay in the order in which they appear in the input .