public static < T extends S , S extends Comparable < S > > T [ ] sortAndRemoveDuplicates ( T [ ] children ) { int r = isSortedAndUnique ( children ) ; switch ( r ) { case 0 : // In this case, the array is already sorted and no duplicates were // found. return children ; case 1 : // In this case, the array is already sorted, but duplicates were // found return ArrayUtils . sortedRemoveDuplicates ( children ) ; default : // In this case, the array is not sorted and may or may not // contain duplicates. children = Arrays . copyOf ( children , children . length ) ; Arrays . sort ( children ) ; return ArrayUtils . sortedRemoveDuplicates ( children ) ; } }
Sort and remove duplicate items from a given array .