code: 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.add(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();
      }
docs: Sets up the index table based on the given list of the same size and
  comparator.
  
  @param <T> the type in use
  @param list the list of points to obtain a sorted IndexTable for
  @param cmp the comparator to determined the sorted order