Search for '{{search_term}}'

Exercise: sort scores

CMOS is the Code-Maven Open Source podcast that also includes video interviews. Subscribe to this feed RSS feed with your Podcast listener app or via iTunes iTunes.

Exercise: sort scrores

See other exercises.

In this exercise you a file with scores. Each line has a name and a number (a score) separated by a comma.

examples/data/score_data.txt

Foo,23
Bar,70
Baz,92
Bozo,17
Gozo,52
Dardon,20
Mekodra,23

The first task is to read in the file and print out the names with their scores ordered by name givin the following result:

Bar      70
Baz      92
Bozo     17
Dardon   20
Foo      23
Gozo     52
Mekodra  23

The second task is to print them ordered by scores resulting in:

Baz      92
Bar      70
Gozo     52
Foo      23
Mekodra  23
Dardon   20
Bozo     17

Tools

Solutions

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus