sort_custom in docs : am I stupid or is it a mistake (or simply confusing)

Godot Version

4.3

Question

In Godot Docs 4.3. About Array “sort_custom” func, quote :

"Sorts the array using a custom Callable.

func is called as many times as necessary, receiving two array elements as arguments. The function should return true if the first element should be moved behind the second one, otherwise it should return false."

Then in the example :
func sort_ascending(a, b):
if a[1] < b[1]:
return true
return false

This is confusing. If you are sorting “ascending” (from lowest to highest), when if a is smaller than b, then a SHOULD NOT be moved behind, therefore it should return FALSE ?

Behind means before the index, so if it was at index 4, it gets moved behind to index 3.

A little confusing but correct none the less.

1 Like