public static <T>ArrayList<T> sortThis(ArrayList<T> list,Comparator<? super T> comparator){
  int size=list.size();
  if (ArrayListIterate.canAccessInternalArray(list)) {
    Arrays.sort(ArrayListIterate.getInternalArray(list),0,size,comparator);
  }
 else {
    Collections.sort(list,comparator);
  }
  return list;
}

public static < T > ArrayList < T > sortThis ( ArrayList < T > list , Comparator < ? super T > comparator ) { int size = list . size ( ) ; if ( ArrayListIterate . canAccessInternalArray ( list ) ) { Arrays . sort ( ArrayListIterate . getInternalArray ( list ) , 0 , size , comparator ) ; } else { Collections . sort ( list , comparator ) ; } return list ; }
mutates the internal array of the arraylist by sorting it and then returns the same arraylist .
