Page 184 -
P. 184

hashes and databases



                     Test Drive




           With the results.txt file saved to the same directory as your program, enter this
           code into IDLE and see what happens. Remember to save your program, then press
           F5 to run it.
















                                                                          These results don't make sense!




















           Those results look a little strange. Zack is only a novice surfer but, according
           to the results from your program, Zack has the highest score. It looks like the
           association between the surfer names and their scores is somehow lost... and if
           you think about it, this is exactly what’s happening.
           The two arrays are independent of each other: one contains scores, the other
           names. When the data is in the file, the surfer name and the scores are associated
           with each other because they appear on the same line. However, once the split
           occurs and the data is in the arrays, the association is severed. Sorting one array
           has no effect on the ordering of the other. No wonder your results are a little off
           the wall.

           How do you fix this?

                                                                                       you are here 4    149
   179   180   181   182   183   184   185   186   187   188   189