Explorar o código

doc: Add an example for `Array.sort()`

This may help people understand the difference between alphabetical
and natural order more quickly.

(cherry picked from commit 1de9118c5fee6201ea1e9eb4be9b00867f536520)
Hugo Locurcio %!s(int64=5) %!d(string=hai) anos
pai
achega
47368f2b7c
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      doc/classes/Array.xml

+ 6 - 1
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">