23 bool swapEntries =
false;
25 if (leftEntry != NULL && rightEntry != NULL)
27 int result = strcmp(leftEntry->
Name, rightEntry->
Name);
28 swapEntries = result > 0;
45 bool swapEntries =
false;
47 if (leftEntry != NULL && rightEntry != NULL)
49 int result = leftEntry->
Age - rightEntry->
Age;
50 swapEntries = result > 0;
67 bool swapEntries =
false;
69 if (leftEntry != NULL && rightEntry != NULL)
72 swapEntries = result > 0;
114 if (strategy != NULL)
static bool _Compare_Height(const EntryInformation *leftEntry, const EntryInformation *rightEntry)
Compare the height fields of two EntryInformation objects to determine if the two entries need to be ...
void SortStrategy_Initialize(SortStrategy *strategy, SortOptions sortOption, bool reversedSort)
Initialize a SortStrategy object with the desired strategy.
static bool _Compare_Age(const EntryInformation *leftEntry, const EntryInformation *rightEntry)
Compare the age fields of two EntryInformation objects to determine if the two entries need to be swa...
static bool _Compare_Name(const EntryInformation *leftEntry, const EntryInformation *rightEntry)
Compare the name fields of two EntryInformation objects to determine if the two entries need to be sw...
static SortStrategyItem sortingStrategies[]
List of sorting strategies as indexed by a value from the SortOptions enumeration....
Declaration of the SortStrategy structure and the SortStrategy_Initialize() function as used in the S...
SortOptions
Represents the difference sorting strategies supported.
bool(* CompareFunction)(const EntryInformation *, const EntryInformation *)
Alias for a function that compares two EntryInformation objects to determine if the left comes before...
Represents an individual with a Name, Age, and Height.
int Age
Age of this individual, in years.
const char * Name
Name of this individual.
int Height
Height of this individual, in inches.
Represents the strategy to use for sorting EntryInformation objects.
bool reversedSort
True if to reverse the order of the sort.
const char * name
Name of the strategy (for display purposes)
CompareFunction compareFunction
Compare function that determines the order of two entries.
Represents a sorting strategy.
const char * name
Name of the sorting strategy.
CompareFunction compareFunction
compare function to use for the sorting strategy