Trouble using 'sort'

Bahman Movaqar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 26 00:23:40 PDT 2016


On 07/26/2016 10:41 AM, Jonathan M Davis via Digitalmars-d-learn wrote:
>> So it may be something about what kind of range I'm passing to `sort`.
>> Am I right?
> 
> sort requires a random access range. Without knowing exactly which
> algorithms your using, I can't say for sure that that's the problem, but
> usually it is. Most of the time, you don't end up with a random access range
> after chaining several range-based functions. You _can_, but it depends
> entirely on which functions they are and the type of your original range.
> 
> It's frequently the case that if you want to sort a range, you have to call
> array() on it to convert it to an array, and then you can sort the array.

Thanks...that explains it.

-- 
Bahman


More information about the Digitalmars-d-learn mailing list