7.4 Sorting and Searching Arrays
A place for everything and everything in its place.
—ISABELLA MARY BEETON, Book of Household Management (1861)
Suppose you have an array of values. You might want the array values to be ordered in some way. For example, you might want to order an array of numbers from lowest to highest or from highest to lowest, or you might want to arrange an array of strings into alphabetical order. Arranging a collection of items into a particular order is called sorting. Typically, we sort arrays into ascending or descending order.
In this section, we will discuss and implement a simple sorting algorithm. We will present this algorithm ...
Get Java: An Introduction to Problem Solving and Programming, 8th 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.