Sorting Exercises
1. Sort the numbers 1, 86, 345, 2, 9,0
into descending order.
2. Sort Tom. Dick, Harry, Joe, Fred, George into ASCII
order.
3. Make a hash with
names as keys and ages as values: Tom = 56, Dick = 14, Harry = 5, Joe = 22,
Fred = 85, George = 14, and sort the people's names into order of their
ages. Print out the name followed by the
age, one set per line.
4. Add in Bob = 56 and Pete = 56, then sort by age first,
then by name.
5. Add in another hash using the occupation of the same people:
Tom = plumber, Dick = ditchdigger, Harry = doctor,
Joe = bum, Fred = professor, George = idiot, Bob = photographer, Pete =
unemployed, sorted by name, then by age.