summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2020-01-31 21:19:17 +0100
committerHugo Locurcio <hugo.locurcio@hugo.pro>2020-01-31 21:23:09 +0100
commit1de9118c5fee6201ea1e9eb4be9b00867f536520 (patch)
tree61b6216e212815a255e15276fbe98ba5f8a8d9ea
parent8eef6d280b42f098e15d0e1e6acf8189ae4be489 (diff)
doc: Add an example for `Array.sort()`
This may help people understand the difference between alphabetical and natural order more quickly.
-rw-r--r--doc/classes/Array.xml7
1 files changed, 6 insertions, 1 deletions
diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml
index 5f100d918e..89ad8e17db 100644
--- a/doc/classes/Array.xml
+++ b/doc/classes/Array.xml
@@ -322,7 +322,12 @@
<method name="sort">
<description>
Sorts the array.
- [b]Note:[/b] strings are sorted in alphabetical, not natural order.
+ [b]Note:[/b] Strings are sorted in alphabetical order (as opposed to natural order). This may lead to unexpected behavior when sorting an array of strings ending with a sequence of numbers. Consider the following example:
+ [codeblock]
+ var strings = ["string1", "string2", "string10", "string11"]
+ strings.sort()
+ print(strings) # Prints [string1, string10, string11, string2]
+ [/codeblock]
</description>
</method>
<method name="sort_custom">