7.5 Sorting

We all know what sorting is. We sort our music playlist, our bookshelves, even our priorities. Sorting is putting things in order. In computing, transforming an unsorted array into a sorted array is a common and useful operation. Entire books have been written about sorting algorithms. The goal is to come up with better, more efficient sorts. Because sorting a large number of elements can be extremely time consuming, a good sorting algorithm is highly desirable. In fact, this is one area in which programmers are sometimes encouraged to sacrifice clarity in favor of speed of execution.

In this section, we present several diverse sorting algorithms to give you a flavor of how many different ways there are to solve the same problem. ...

Get Computer Science Illuminated, 7th Edition 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.