public void sort(ArrayList<Value[]> rows,int offset,int limit){
  int rowsSize=rows.size();
  if (rows.isEmpty() || offset >= rowsSize || limit == 0) {
    return;
  }
  if (offset < 0) {
    offset=0;
  }
  if (offset + limit > rowsSize) {
    limit=rowsSize - offset;
  }
  if (limit == 1 && offset == 0) {
    rows.set(0,Collections.min(rows,this));
    return;
  }
  Value[][] arr=rows.toArray(new Value[rowsSize][]);
  Utils.sortTopN(arr,offset,limit,this);
  for (int i=0, end=Math.min(offset + limit,rowsSize); i < end; i++) {
    rows.set(i,arr[i]);
  }
}

public void sort ( ArrayList < Value [ ] > rows , int offset , int limit ) { int rowsSize = rows . size ( ) ; if ( rows . isEmpty ( ) || offset >= rowsSize || limit == 0 ) { return ; } if ( offset < 0 ) { offset = 0 ; } if ( offset + limit > rowsSize ) { limit = rowsSize - offset ; } if ( limit == 1 && offset == 0 ) { rows . set ( 0 , Collections . min ( rows , this ) ) ; return ; } Value [ ] [ ] arr = rows . toArray ( new Value [ rowsSize ] [ ] ) ; Utils . sortTopN ( arr , offset , limit , this ) ; for ( int i = 0 , end = Math . min ( offset + limit , rowsSize ) ; i < end ; i ++ ) { rows . set ( i , arr [ i ] ) ; } }
sort a list of rows using offset and limit .
