Like a lot of people I have been following the Olympics lately. For all the talk about sport and individual and team achievement there is always a lot of attention to what countries are “winning.” Conveniently there are lots of places online where you can view current medal totals and see how each country is doing.
There seem to be two ways to list what country is "winning" in the Olympics though. One is in total number of medals regardless of type.
The other is sorting first by Gold, then Silver and then Bronze. So most gold is first even if they don't have any other medals. In a tie for Gold then how many Silver determines a "winner". Tie of Gold and Silver is broken by number of Bronze.
There's also a third way: By totaling points where gold=3, silver=2, bronze=1. I haven’t seen that way lately but am told some people use it.
Which way is the right way? I suppose that depends on how you choose to look at things. If you are Norwegian or from the US you might prefer the list be ordered by total medals. At least as of the day I captured these screen shots. If you are German or Swiss then sorting by Gold first may be your preference.
I see a lesson in computing here. One could easily create some sort of class to hold Olympic totals. By changing how the CompareTo method is implemented either sort would work just as well. I’m not teaching AP CS this semester and we’re not going to have enough time in my Honors Programming class (just one semester long) to do this but in the back of my mind I want to remember this as a good example for the future.
Anyone else tried something like this? What did you use for different ways of sorting? How did it work for you?
[Edit: I have a list of resources for teaching sorting at http://blog.acthompson.net/2014/03/resources-for-learning-sorts.html ]