Data can come from a variety of sources and it can be stored in various manners . Like for example , we can store data in a list , in a dictionary , or in a string . The question hence is how to sort data , when one needs to do so ?

In python , instead of creating our own sorting algorithm , or our own sorting function , we can use the sorted function , which has a worst case performance – of O(n log n ).

sorted in python a tutorial featured image 247 by 217

An object has a type which defines its attributes and methods . For example the str type define the attributes and method for a string object.

An object has also an id which is its memory address , and a value for example 1 or 'a'

To compare objects in python , we can implement python comparison methods __eq__ , __ne__ , __lt__ , __gt__ , __ge__ , __le__ . In this article we will show how to implement these methods and how they work .

comparison in python a tutorial featured image 205 by 246
« Previous Next »