[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: In a sorted integer list FindSorted Fails if there is more than one instance of value!
[Thread Prev] | [Thread Next]
- Subject: Re: In a sorted integer list FindSorted Fails if there is more than one instance of value!
- From: Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
- Date: Fri, 12 Sep 2025 01:20:04 +0200
- To: user@xxxxxxxxxxxxxxxxxxxxxx
Le 11/09/2025 à 22:04, Brian G a écrit :
I am not sure I understand how array.findSorted should work, but it appears to never find the first instance of a value in a sorted list when there is more than one instance of the value, seems to be random.
It's not random, it's the documentation that is inaccurate.FindSorted() is just a binary search, and so never find the *first* element in array order, but the first it encounters while following the binary search order.
Returning the first occurence in array order would be a performance penalty, and I don't understand how it would be useful. Please elaborate!
Regards, -- Benoît Minisini.
In a sorted integer list FindSorted Fails if there is more than one instance of value! | Brian G <brian@xxxxxxxxxxxxxxxx> |