Merge pull request #96118 from aaronp64/sort_custom_example
Fix `Array.sort_custom` example code
This commit is contained in:
commit
b5603ed8e2
1 changed files with 1 additions and 1 deletions
|
@ -728,7 +728,7 @@
|
||||||
print(my_items) # Prints [["Rice", 4], ["Tomato", 5], ["Apple", 9]]
|
print(my_items) # Prints [["Rice", 4], ["Tomato", 5], ["Apple", 9]]
|
||||||
|
|
||||||
# Sort descending, using a lambda function.
|
# Sort descending, using a lambda function.
|
||||||
my_items.sort_custom(func(a, b): return a[0] > b[0])
|
my_items.sort_custom(func(a, b): return a[1] > b[1])
|
||||||
print(my_items) # Prints [["Apple", 9], ["Tomato", 5], ["Rice", 4]]
|
print(my_items) # Prints [["Apple", 9], ["Tomato", 5], ["Rice", 4]]
|
||||||
[/codeblock]
|
[/codeblock]
|
||||||
It may also be necessary to use this method to sort strings by natural order, with [method String.naturalnocasecmp_to], as in the following example:
|
It may also be necessary to use this method to sort strings by natural order, with [method String.naturalnocasecmp_to], as in the following example:
|
||||||
|
|
Loading…
Reference in a new issue