src/GenFx/GeneticEntityCollectionExtensions.cs
/// <summary>
/// Sorts the list in the order by the fitness type indicated, from worst to best.
/// </summary>
/// <param name="entities">The entities to sort.</param>
/// <param name="sortBasis">Type of fitness value on which sorting is based.</param>
/// <param name="evaluationMode">Mode which indicates whether the sorting will be based on higher or lower fitness values.</param>
/// <exception cref="ArgumentException"><paramref name="sortBasis"/> value is undefined.</exception>
/// <exception cref="ArgumentException"><paramref name="evaluationMode"/> value is undefined.</exception>
Sorts the list in the order by the fitness type indicated, from worst to best.
Sorts the list in the order by the fitness type indicated from worst to best .
public static IEnumerable<GeneticEntity> GetEntitiesSortedByFitness(this IEnumerable<GeneticEntity> entities,  FitnessType sortBasis, FitnessEvaluationMode evaluationMode)
        {
            if (!Enum.IsDefined(typeof(FitnessType), sortBasis))
            {
                throw EnumHelper.CreateUndefinedEnumException(typeof(FitnessType), "sortBasis");
            }
            if (!Enum.IsDefined(typeof(FitnessEvaluationMode), evaluationMode))
            {
                throw EnumHelper.CreateUndefinedEnumException(typeof(FitnessEvaluationMode), "evaluationMode");
            }
            FitnessValueComparer comparer = new FitnessValueComparer(sortBasis);
            GeneticEntity keySelector(GeneticEntity entity) => entity;
            if (evaluationMode == FitnessEvaluationMode.Maximize)
            {
                return entities.OrderBy(keySelector, comparer);
            }
            else
            {
                return entities.OrderByDescending(keySelector, comparer);
            }
        }
public static IEnumerable < GeneticEntity > GetEntitiesSortedByFitness ( this IEnumerable < GeneticEntity > entities , FitnessType sortBasis , FitnessEvaluationMode evaluationMode ) { if ( ! Enum . IsDefined ( typeof ( FitnessType ) , sortBasis ) ) { throw EnumHelper . CreateUndefinedEnumException ( typeof ( FitnessType ) , " " ) ; } if ( ! Enum . IsDefined ( typeof ( FitnessEvaluationMode ) , evaluationMode ) ) { throw EnumHelper . CreateUndefinedEnumException ( typeof ( FitnessEvaluationMode ) , " " ) ; } FitnessValueComparer comparer = new FitnessValueComparer ( sortBasis ) ; GeneticEntity keySelector ( GeneticEntity entity ) => entity ; if ( evaluationMode == FitnessEvaluationMode . Maximize ) { return entities . OrderBy ( keySelector , comparer ) ; } else { return entities . OrderByDescending ( keySelector , comparer ) ; } }
Sorts the list in the order by the fitness type indicated, from worst to best.
Sorts the list in the order by the fitness type indicated from worst to best .
value is undefined.
value is undefined .
value is undefined.
value is undefined .
IEnumerable<GeneticEntity>
this
sortBasis
FitnessType
Type of fitness value on which sorting is based.
Type of fitness value on which sorting is based .
evaluationMode
FitnessEvaluationMode
Mode which indicates whether the sorting will be based on higher or lower fitness values.
Mode which indicates whether the sorting will be based on higher or lower fitness values .
entities
The entities to sort.
The entities to sort .