Skip to content

Make Array.sort_custom callable requirements more explicit for the a == b case #10816

Open
godotengine/godot
#104944
@harrison-munitz

Description

@harrison-munitz

Your Godot version:
4.4

Issue description:
If the sorting function provided to sort_custom returns true when a == b (E.g. using <= instead of just <), you will get an error that reads:

bad comparison function; sorting will be broken

The existing documentation does technically describe the correct expected behavior of the callable, but it could stand to be more explicit. I propose adding the following sentence to the main part of the method description (before the first code-example) to make the expected behavior completely unambiguous:

If the order of the two elements does not matter (E.g. they are equal), it should return false.

URL to the documentation page (if already existing):
https://docs.godotengine.org/en/stable/classes/class_array.html#class-array-method-sort-custom

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:class referenceIssues and PRs about the class reference, which should be addressed on the Godot engine repositoryenhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions