Exercise #4: Sorting

The text file /u2/stone/datasets/hitters.dat is supposed to contain statistics about the careers of 130 baseball players, one on each line, in the following format:

Here's a sample line:
Kiner                   5205 1451 216  39 369 1015 .279 .548 .397
Let us define the disparity between two players as the sum of the following quantities:

Each of these differences should always be non-negative. (In other words, you should take the absolute value of the result of subtracting one number from the other.)

The assignment is to find and print out, for each of the players, which five other players are ``most similar'' to him (in the sense that their disparity from him is smallest). The output should consist of six lines for each player, with the player's name on the first line and the five most similar players and their computed disparities, in ascending order by disparity, on subsequent lines. Thus the output for each player should look like this:

Most similar to Hackman:
  Wilde (disparity 1199)
  Flakey (disparity 1416)
  Stryke (disparity 1644)
  Leimo (disparity 2209)
  Whiffer (disparity 2262)
The entries themselves should be printed in alphabetical order by player's name.

This exercise will be due on Wednesday, October 9.


created October 1, 1996
last revised October 2, 1996