is it possible to sort a float range ?
Steven Schveighoffer
schveiguy at gmail.com
Thu Jun 24 00:32:31 UTC 2021
On 6/23/21 7:07 PM, someone wrote:
> On Wednesday, 23 June 2021 at 22:46:28 UTC, Steven Schveighoffer wrote:
>
>> Use the `release` method:
>>
>> ```d
>> return lnumRange.sort!(...).release;
>> ```
>>
>
> Fantastic, issue solved, I previously used sort ascending even
> descending but first time on floats.
>
> So I went and searched phobos docs:
>
> auto release();
> Releases the controlled range and returns it.
>
> Not much clarification there.
>
> Can you elaborate a bit if possible Steve ?
I think the purpose behind it is to say "here, now you have the original
range back, so I won't guarantee it's sorted any more." I'm pretty sure
it also clears out the source range in the sorted range, so you can no
longer use the sortedness functions, but that's easily circumvented
using `save`.
I can't really defend the purpose/implementation of `SortedRange`, it's
something in Phobos that I've complained about extensively in the past.
-Steve
More information about the Digitalmars-d-learn
mailing list