August 27, 2009
C Snippet #3Bob Stout
Sorting an array of strings
Q: HOW DO I... sort an array of strings?
A: Sorting jobs come in all sizes. One of the most common is simply sorting an array of strings. Unless the array is very large, the standard qsort() function is often inefficient for such tasks. In such situations, you might consider the Shell sort presented in this Snippet. Call it with only two arguments, a pointer to the string array to sort and the number of strings in the array.
More C Snippets
All the code in C Snippets is either public domain or freeware and may therefore freely be used by the C programming community without restrictions. In most cases, if the original author is someone other than myself he or she will be identified. Thanks to all who have contributed to this collection over the years. I hope Dr. Dobb's readers will find these useful.
--Bob Stout
|
|
||||||||||||||||||||||||||||
|
|
|
|