class TruncationSelectionOperator extends AbstractSelectionOperator {

    public Population[] select(Population[] populations) {
        checkConsistency(populations);

        List<Individual> allIndividuals = Arrays.asList(this.concatenateIndividualsFromPopulations(populations, this.inputArity));
        // sorting according to fitness in reversed order -> fittest first
        Collections.sort(allIndividuals, Collections.reverseOrder());

        // prepare result and map selected Individuals into resulting arrays
        int resultSize = this.individualsPerPopulation * this.outputArity;
        List<Individual> resultingIndividuals = allIndividuals.subList(0, resultSize);

        // making resulting array
        Population[] outputPopulations = this.createOutputPopulations();
        Individual[][] outputIndividuals = this.createOutputIndividuals();
        this.assignIndividualsToPopulations(outputIndividuals, outputPopulations);
        this.mapByColumns(resultingIndividuals, outputIndividuals);

        return outputPopulations;
    }

}