ExampleGet your own Python Server Sort the list alphabetically: thislist = ["orange","mango","kiwi","pineapple","banana"] thislist.sort() print(thislist) Try it Yourself » Example Sort the list numerically: thislist = [100,50,65,82,23] ...
ExampleGet your own Python Server Sort the list alphabetically: cars = ['Ford','BMW','Volvo'] cars.sort() Try it Yourself » Definition and Usage Thesort()method sorts the list ascending by default. You can also make a function to decide the sorting criteria(s). ...
ExampleGet your own Python Server Sort the result alphabetically by name: import pymongomyclient = pymongo.MongoClient("mongodb://localhost:27017/") mydb = myclient["mydatabase"]mycol = mydb["customers"] mydoc = mycol.find().sort("name")for x in mydoc: print(x) Run example » ...