0 votes

Sort on an array of Vector3 returns Nil.

Godot version 3.2
in Engine by (14 points)

1 Answer

0 votes

sort() is a void method, so it doesn't return anything. Instead, it directly sorts the array it's called on. So...

your_array.sort()

... will directly sort your_array.

That said, I'm not sure what it'll do with a an array of Vector3. If it doesn't do what you want / expect, you may wan to to use sort_custom() instead.

https://docs.godotengine.org/en/stable/classes/class_array.html?highlight=array#class-array-method-sort-custom

by (10,884 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.