You can download this code by clicking the button below.
This code is now available for download.
This function sorts a list based on a given key. If the input is not a list, it converts it into one.
Technology Stack : Built-in function: sorted(), lambda expression
Code Type : Sort function
Code Difficulty : Beginner
def aord(arg1, arg2):
return sorted(arg1 if isinstance(arg1, list) else [arg1], key=lambda x: arg2(x))