How it works...

Step 1 is just defining the method. In step 2, we call the sorted() method in the recordset of books. Internally, the sorted() method will fetch the data of the field that's passed as the key argument. Then, by using Python's native sorted method, it returns a sorted recordset.

It also has one optional argument, reverse=True, which returns a recordset in reverse order. reverse is used as follows:

books.sorted(key='release_date', reverse=True)
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset