@SuppressWarnings("unchecked") @Override public Array<T> sorted(Comparator<? super T> comparator) { final Object[] arr = toArray(this); Arrays.sort(arr, (o1, o2) -> comparator.compare((T) o1, (T) o2)); return wrap(arr); }
/** * Creates a Array of the given elements. * * @param <T> Component type of the Array. * @param elements Zero or more elements. * @return A Array containing the given elements in the same order. * @throws NullPointerException if {@code elements} is null */ @SuppressWarnings("varargs") @SafeVarargs public static <T> Array<T> of(T... elements) { Objects.requireNonNull(elements, "elements is null"); return wrap(Arrays.copyOf(elements, elements.length)); }
@Override public Array<T> sorted() { final Object[] arr = toArray(this); Arrays.sort(arr); return wrap(arr); }