doc: Add an example for Array.sort()

This may help people understand the difference between alphabetical
and natural order more quickly.
This commit is contained in:
Hugo Locurcio 2020-01-31 21:19:17 +01:00
parent 8eef6d280b
commit 1de9118c5f
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C

View file

@ -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">