Content deleted Content added
→List of languages: Trade X for a check mark |
→Sorting: Explain the motivation a bit more |
||
Line 10:
===Sorting===
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 to items and the function indicates if they are equal or if one is "greater" or "less" than the other.
Consider sorting items in a list by the name of their class (everything in python has a class):
<source lang="python">
|