the bibliography class hasas its main attributea list of entries which are instances of book and article classes rememberinstances of book and article can be thought of as books and articlesthe instances are the "objectsthat specific books and articles are nextwe write methods for bibliography that can manipulate the list of book and article instances to that endthe first two methods we write for bibliography will do the followinginitialize an instance of the classrearrange the list alphabetically based upon last name then first name the initialization method is called init (as always)and the rearranging method will be called sort entries alpha here is the code import operator class bibliography(object)def __init__(selfentrieslist)self entrieslist entrieslist def sort_entries_alpha(self)tmp sorted(self entrieslistkey=operator attrgetter('authorlast''authorfirst')self entrieslist tmp del tmp let' talk about what this code does in the init methodthere is only single argumententrieslist this is the list of book and article instances that are being passed into an instance of the bibliography class the init method assigns the entrieslist argument to an attribute of the same name lines - define the sort entries alpha methodwhich sorts the entrieslist attribute and replaces the old entrieslist attribute with the sorted version the method uses the built-in sorted functionwhich takes keyword parameter key that gives the key used for sorting the argument of sorted how is that key generatedthe attrgetter functionwhich is part of the the operator modulegets the attributes of the names listed as arguments attrgetter to attrgetter out of the elements of the item being sorted (note that the function and attribute names passed into attrgetter are stringsand thus you refer to the sorted attributes of interest by their string namesnot by typing in their names this makes the program much easier to write in our exampleattrgetter has two argumentssorted indexes self entrieslist by the attrgetter' first argument attribute name first then the second