code: public static <T> void sortEvaluatedPopulation(List<EvaluatedCandidate<T>> evaluatedPopulation,
                                                     boolean naturalFitness)
      {
          // Sort candidates in descending order according to fitness.
          if (naturalFitness) // Descending values for natural fitness.
          {
              Collections.sort(evaluatedPopulation, Collections.reverseOrder());
          }
          else // Ascending values for non-natural fitness.
          {
              Collections.sort(evaluatedPopulation);
          }
      }
docs: Sorts an evaluated population in descending order of fitness
  (descending order of fitness score for natural scores, ascending
  order of scores for non-natural scores).
  
  @param evaluatedPopulation The population to be sorted (in-place).
  @param naturalFitness True if higher fitness scores mean fitter individuals, false otherwise.
  @param <T> The type of entity that is being evolved.