Skip to Content
Absolute Beginner's Guide to Programming, Third Edition
book

Absolute Beginner's Guide to Programming, Third Edition

by Greg Perry
November 2002
Beginner content levelBeginner
432 pages
11h 44m
English
Que
Content preview from Absolute Beginner's Guide to Programming, Third Edition

Sorting

Your programs can sort lists of values in different ways. Perhaps the list was sorted previously, and now you want to reverse the sort. A reversed sort may be appropriate, for example, to print customer balances from the highest balance to the lowest.

Consider the following list of numbers that is not sorted:

10 54 34 46 23

Here is the list sorted in ascending order (from lowest to highest):

10 23 34 46 54

Here is the list sorted in descending order (from highest to lowest):

54 46 34 23 10

Of course, your program can also sort character string data, such as a list of names. When sorting strings, the computer uses the ASCII table to sort the values in alphabetical order.

There are several ways to sort data. The most popular one for beginning ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Absolute Beginner's Guide to Programming, Second Edition

Absolute Beginner's Guide to Programming, Second Edition

Greg Perry

Publisher Resources

ISBN: 0789729059Purchase book