private List<Population<NSGA2Chromosome>> nonDominatedSort(Population<NSGA2Chromosome> population) {
        Population<NSGA2Chromosome> sortingPopulation = new Population<NSGA2Chromosome>(population);
        ArrayList<Population<NSGA2Chromosome>> fronts = new ArrayList<Population<NSGA2Chromosome>>();
        DominanceComparator dominanceComparator = new DominanceComparator();

        int currentRank = 0;
        while (!sortingPopulation.isEmpty()) {
            int[] dominatedArray = new int[sortingPopulation.size()];
            for (int i = 0; i < sortingPopulation.size(); i++) {
                for (int j = 0; j < sortingPopulation.size(); j++) {
                    if (i == j) continue;
                    int compare = dominanceComparator.compare(sortingPopulation.get(i), sortingPopulation.get(j));
                    if (compare < 0) {
                        dominatedArray[i]++;
                    }
                }
            }
            Population<NSGA2Chromosome> currentFront = new Population<NSGA2Chromosome>();
            fronts.add(currentFront);
            for (int i = 0; i < dominatedArray.length; i++) {
                if (dominatedArray[i] == 0) {
                    NSGA2Chromosome currentRankChromosome = sortingPopulation.get(i);
                    currentRankChromosome.setRank(currentRank);
                    currentFront.add(currentRankChromosome);
                }
            }
            sortingPopulation.removeAll(currentFront);
            currentRank++;
        }
        return fronts;
    }