Page 189 -
P. 189

comprehending data



                         Test Drive




                       Combine your sanitize() function with your amended code from the previous page, and then
                        press F5 in IDLE to confirm the sorting is now working as expected.

                  The sanitized data only
                  contains ‘.’ as a separator.














                     The ordering works, because all the                                  Four sorted
                     times are now comparable.                                            lists


           This output looks much better.
           It’s taken a bit of work, but now the data from each of the four files is both
           sorted and uniformly formatted. By preprocessing your data before you
           sort it, you’ve helped ensure Python’s sorting technology performs correctly.




                                          Geek Bits




                                 By default, both the sort() method and the sorted()
                                 BIF order your data in ascending order. To order your data in
                                 descending order, pass the reverse=True argument to
                                 either sort() or sorted() and Python will take care of
                                 things for you.












                                                                                      you are here 4    153
   184   185   186   187   188   189   190   191   192   193   194