Chapter 12. Sorting: Bringing Order Out Of Chaos

Being able to build the right data structure or collection class for a particular application is only half the battle. Unless the data sets in your problem domain are very small, any collection of your data will benefit from a little organization. Organizing the elements in your list or collection by a particular value or set of values is known as sorting.

Sorting your data is not strictly necessary, but doing so makes searching or lookup operations much more efficient. Likewise, when you need to merge multiple collections of data together, having the various collections sorted in advance of the merge can greatly improve the efficiency of the merge operation.

If your data is a collection of numeric ...

Get Everyday Data Structures now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.