The sort() method of list objects in Python is quite flexible. By default, it sorts on the first thing in each item of the list, which is exactly what you would expect. For example, a list of strings is sorted by the first letter of each string. What if you wanted to sort by the second letter of each string? Or sort a list of people’s names by last name? Continue reading ‘Advanced sorting: sorting by key’
Recent Posts
- Minimal Sphinx setup for autodocumenting Python modules
- Write Excel files with Python using xlwt
- Python script to package Latex projects for distribution
- RPy: statistics in R from Python
- Polar bar plot in Python
- Record screencasts, convert to Flash, and embed on your site
- Interactive subplots: make all x-axes move together
- Calculate sunrise and sunset with PyEphem
- Use Sphinx for documentation
- Insert content into TiddlyWikis with this Python script
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Apr | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | ||||