private static int[] sortedSlice(int[] valueSequence,int start,int end){
  if (start == 0 && end == valueSequence.length && isSorted(valueSequence,0,false)) {
    return valueSequence;
  }
 else {
    int[] slice=new int[end - start];
    System.arraycopy(valueSequence,start,slice,0,slice.length);
    Arrays.sort(slice);
    return slice;
  }
}

private static int [ ] sortedSlice ( int [ ] valueSequence , int start , int end ) { if ( start == 0 && end == valueSequence . length && isSorted ( valueSequence , 0 , false ) ) { return valueSequence ; } else { int [ ] slice = new int [ end - start ] ; System . arraycopy ( valueSequence , start , slice , 0 , slice . length ) ; Arrays . sort ( slice ) ; return slice ; } }
slice and sort the given input array .
