Fix miscellaneous oddities around the class reference (part 4)

This commit is contained in:
Micky
2025-04-04 23:44:50 +02:00
parent 27b2ba667c
commit e935fb1ee2
17 changed files with 44 additions and 38 deletions

View File

@ -477,7 +477,15 @@
<method name="sort">
<return type="void" />
<description>
Sorts the dictionary in-place by key. This can be used to ensure dictionaries with the same contents produce equivalent results when getting the [method keys], getting the [method values], and converting to a string. This is also useful when wanting a JSON representation consistent with what is in memory, and useful for storing on a database that requires dictionaries to be sorted.
Sorts the dictionary in ascending order, by key. The final order is dependent on the "less than" ([code]&lt;[/code]) comparison between keys.
[codeblocks]
[gdscript]
var numbers = { "c": 2, "a": 0, "b": 1 }
numbers.sort()
print(numbers) # Prints { "a": 0, "b": 1, "c": 2 }
[/gdscript]
[/codeblocks]
This method ensures that the dictionary's entries are ordered consistently when [method keys] or [method values] are called, or when the dictionary needs to be converted to a string through [method @GlobalScope.str] or [method JSON.stringify].
</description>
</method>
<method name="values" qualifiers="const">