Page 173 -
P. 173
sort then reverse
SOlUTion
These are some of the methods that come built into every array. You
were to match up the descriptions with the method names:
Method What the method does
count() Sorts the array into a specified order (low to high)
extend() Removes and returns the last array item
index() Adds an item at any index location
insert() Looks for an item and returns its index value
pop() Reverses the order of the array
remove() Tells you how many times a value is in the array
reverse() Adds a list of items to an array
sort() Removes and returns the first array item
SOlUTion
You were to work out which two methods you needed to employ to
allow you to sort the data in the order that you needed.
The sort() and reverse() methods look the most useful. You
need to use reverse() after you sort() the data, because the
default ordering used by sort() is lowest-to-highest, the opposite
of what you need.
138 Chapter 4