Here you can find the source of sort(O[] array)
Parameter | Description |
---|---|
array | the array to sort |
public static <O extends Comparable<O>> O[] sort(O[] array)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.Comparator; public class Main { /**/* www . j ava 2 s . c o m*/ * Sorts the given array by its natural order of objects and then returns it, assuming the natural order of the elements follows the {@link Comparable} contract. * @param array the array to sort * @return the given array after sorting it */ public static <O extends Comparable<O>> O[] sort(O[] array) { Arrays.sort(array); return array; } /** * Sorts the given array by the order dictated by the comparator and then returns it, assuming the Comparator follows the {@link Comparable} contract. * @param array the array to sort * @param comparator the Comparator to sort the elements by * @return the array after sorting it */ public static <O> O[] sort(O[] array, Comparator<? super O> comparator) { Arrays.sort(array, comparator); return array; } }