#Am I using array_sort wrong ?

1 messages · Page 1 of 1 (latest)

topaz sage
#

I'm sorting these structs based on the priorityvalue, but they're sorted in the wrong order (here for instance it should be 224,222,223).
I can see what's wrong with my very basic sorting algorithm.
I haven't touched math_set_epsilon so this shouldn't be acceptable rounding error.
I'm out of ideas 😵‍💫

solar scaffold
#

What if you multiple it by 100 .. just out of curiosity... Also in the parking lot on my phone so I can't test anything

charred thicket
#

need to use sign() on the return i believe i.e.

return sign(_elem1.priority - _elem2.priority);
#

this has caught me out many times, including recently

topaz sage
#

oooooooooooooh

#

I think it's the documentation exemple that mislead me, I skipped over the fact that the array in the exemple only contains values that are one apart (and not missing any)

charred thicket
#

yep

topaz sage
#

worth messaging matharoo about it ?

charred thicket
#

bug report i think