def findBestSolutions(population, eaConfig):
    """
    Function to get the best individuals of a populations according to their fitness value. The number of individuals
    to return is given by  EAConfigurations.NUM_BEST_SOLUTIONS parameter.

    Args:
        population (list): list of individuals returned by EA
        eaConfig (EAConfigurations): EA configuration object

    Returns: list of best individuals

    """
    bestPop = {}
    bestFitnessOrder = [-1] * eaConfig.NUM_BEST_SOLUTIONS
    minFitness = -1

    for ind in population:
        if ind.fitness > minFitness:
            minFitness = ind.fitness
            bestFitnessOrder.sort(reverse=True)
            toRem = bestFitnessOrder.pop()
            bestFitnessOrder.append(ind.fitness)
            if len(bestPop) >= eaConfig.NUM_BEST_SOLUTIONS:
                del bestPop[toRem]
            bestPop[ind.fitness] = ind

    return bestPop.values()