Content deleted Content added
m →Sorting: Typo |
→Sorting: Usually indicated by a number |
||
Line 11:
When attempting to sort in a non-standard way it may be easier to contain the comparison logic as an anonymous function instead of creating a named function.
Most languages provide a generic sort function that implements a [[sort algorithm]] that will sort arbitrary objects.
This function usually accepts an arbitrary comparison function that is supplied two items and the function indicates if they are equal or if one is "greater" or "less" than the other (typically indicated by returned a negative number, zero, or a positive number).
Consider sorting items in a list by the name of their class (everything in python has a class):
|