merely-useful / py-rse

Research Software Engineering with Python course material

Home Page:http://third-bit.com/py-rse/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with exercise 3.8.7

sida-wang opened this issue · comments

Given titles.txt as

Sense and Sensibility,1811
Frankenstein,1818
Jane Eyre,1847
Wuthering Heights,1847
Moby Dick,1851
The Adventures of Sherlock Holmes,1892
The Time Machine,1895
Dracula,1897
The Invisible Man,1897

from exercise 3.8.5, options 3 and 4 (listed below) from exercise 3.8.7 give the same answer. Here the goal is to generate a frequency table of publishing year.
3. cut -d, -f 2 titles.txt | uniq -c
4. cut -d, -f 2 titles.txt | sort | uniq -c

However the solutions state that 3 is incorrect. The main issue here is that titles.txt is already sorted by year which means the sort in option 4 has no effect. Instead of updating the solution, it seems more appropriate to sort titles.txt alphabetically which would make option 3 incorrect.

Thanks, @sida-wang! I like your suggestion of simply sorting titles.txt alphabetically. I've done that in #595.