def _sort_by_fitness(parameters, fitness):
    """Given a parameters and fitness array, returns the same arrays but sorted
    in ascending order of the fitness.

    Args:
        fitness (numpy array): As a numpy array, the values for the fitness.
        parameters (numpy array): As a numpy array, the values for the
            parameters.

    Returns:
        sorted_parameters, sorted_fitness: the sorted numpy arrays.
    """
    best_fitness_inds = fitness.argsort()
    sorted_fitness = fitness[best_fitness_inds[::]]
    sorted_parameters = parameters[best_fitness_inds[::]]
    return sorted_parameters, sorted_fitness