From 39ca8b4e23c1d27273cfe31e2fa95da137f36739 Mon Sep 17 00:00:00 2001 From: aaronp64 Date: Mon, 26 Aug 2024 10:38:23 -0400 Subject: [PATCH] Fix Array.sort_custom example code Array.sort_custom descending sort example was comparing index 0, but had expected result based on comparing index 1. Updated to use index 1 consistently. --- doc/classes/Array.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index b60a65e9890..34dffe63871 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -728,7 +728,7 @@ print(my_items) # Prints [["Rice", 4], ["Tomato", 5], ["Apple", 9]] # 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]] [/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: