32 Working with List: sorting and other operations
After reading this lesson, you will be able to:
- Sort a list
- Produce a string representation of a sequence
- Sum all the numerical elements of a list
- Group items according to given criteria
In the previous lesson, you have discovered how to filter elements of a sequence. In this lesson, I am going to introduce you to a miscellanea of operations you can perform on lists. You are going to discover different approaches to sorting the items of a sequence. Also, you are going to learn how to produce a text representation for it. Finally, you are doing to see how to restructure your list into a dictionary-like structure that groups elements with common features. In the capstone, you are going to use these operations to rank the films in the Movies Dataset, and display the result of your data analysis in a human-readable form.
32.1 Sorting elements
In this unit, you have developed a software program to manage an address book in which you have represented each contact as shown in listing 32.1.