You can download this code by clicking the button below.
This code is now available for download.
This function is used to sort a list of tuples based on the first element of each tuple, and if the first elements are the same, it will sort based on the second element.
Technology Stack : Sorting
Code Type : Function
Code Difficulty : Intermediate
def aord(arg1, arg2):
"""
Sort a list of tuples based on the first element and then on the second element.
"""
return sorted(arg1, key=lambda x: (x[0], x[1]))