1. Modify your previous program. After a list of student names are read, sort them by the first name in ascending order before they are printed out.
  2. Note that adding a statement "group.sort()" is not a correct solution. For a list consisting of simple numbers like lst = [3, 1, 4, 1, 5, 9], Python knows how to perform lst.sort(). However, because our list now consists of objects (belonging to the Student class), Python has no idea how we want to compare these objects. Are we comparing by the first name? Or are we comparing by the family name? You must specify which "key" you want to use in comparing these object.
  3. You may define a method getName() in the Student class, and tell python to execute group.sort(key=Student.getName).
  4. The results show that English names are displayed before Chinese names, because the UTF-8 code of Chinese characters are larger than English characters (ASCII code 65~90).
    Julia Roberts
    Sandra Bullock
    ¬h©v¤¸
    ĬªF©Y