Chapter
Sorting Pointers to Elements
From ComputerScienceOne by Dr Chris Bourke
Concepts
- Why is it more efficient to sort pointers to structures?
"Recall that it is sometimes preferable to maintain an array of pointers to structures rather than an array of structures. Sorting is a scenario where this is particularly true. When sorting an array
- How can qsort() sort an array of strings using pointers?
"A prime example of sorting an array of pointers to structures is sorting an array of strings. An array of strings can be thought of as a 2-dimensional array of chars. Specifically, an array of string
- How should a comparator handle an array of structure pointers with NULL values?
"This is essentially equivalent to the string scenario: we have an array of pointers to be sorted, our comparator function then needs to deal with pointers to pointers. An example appears in Code Samp