Tuesday, February 18, 2014

Sorting Isn’t Always Simple

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 theimage 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.image
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 ]

3 comments:

Mike Zamansky said...

Not sorting, but you could have lots of fun turning this into a data problem.

You mention weighting the medals - so you've got three weighted features describing a country.

By itself it isn't so much but one could probably easily get other data - country's population, number of teams, number of popular professional sports, country's gdp and who knows what else.

Now, what can we learn from this? Do larger country's get more gold? More medals? What about GDP or # of professional sports teams.

Many many data mining possibilities.

Of course, once we look at the data it all might be a bust, but it could be a really fun unit.

Garth said...

An addition to Mike's idea; number of athletes at Olympics, number of events entered, number of athletes trying one event, etc. If a country only enters one event and wins gold, is that better than a country that enters 20 events and only wins one gold? Or a country has 5 athletes in one event and another has only one athlete yet takes a medal. This could get very interesting.

Alfred Thompson said...

I'm gathering a bunch of Olympic data for uses in class. I have the breakdown of what states US Winter Olympians come from and the populations of those states for example. I also want to get the data for metals compared to national populations. There is just so much potentially interesting data here.