public < T > void sort ( List < T > list , Comparator < T > cmp ) { if ( index . size ( ) < list . size ( ) ) for ( int i = index . size ( ) ; i < list . size ( ) ; i ++ ) index . ( i ) ; if ( list . size ( ) == index . size ( ) ) Collections . sort ( index , new IndexViewCompList ( list , cmp ) ) ; else { Collections . sort ( index ) ; //so [0, list.size) is at the front Collections . sort ( index . subList ( 0 , list . size ( ) ) , new IndexViewCompList ( list , cmp ) ) ; } prevSize = list . size ( ) ; }
Sets up the index table based on the given list of the same size and comparator .