code: public static <S> int findIndexOfBestSolution(List<S> solutionList, Comparator<S> comparator) {
      if (solutionList == null) {
        throw new NullSolutionListException();
      } else if (solutionList.isEmpty()) {
        throw new EmptySolutionListException();
      } else if (comparator == null) {
        throw new JMetalException("The comparator is null");
      }
  
      int index = 0;
      S bestKnown = solutionList.get(0);
      S candidateSolution;
  
      int flag;
      for (int i = 1; i < solutionList.size(); i++) {
        candidateSolution = solutionList.get(i);
        flag = comparator.compare(bestKnown, candidateSolution);
        if (flag == 1) {
          index = i;
          bestKnown = candidateSolution;
        }
      }
  
      return index;
    }
docs: Finds the index of the best solution in the list according to a comparator
  
  @param solutionList
  @param comparator
  @return The index of the best solution