On Thursday, 8 June 2017 at 01:57:47 UTC, Andrew Edwards wrote:
Ranges may be finite or infinite but, while the destination may be unreachable, we can definitely tell how far we've traveled. So why doesn't this work?
...
If I hand you a chihuahua for grooming, why am I getting back a pit bull? I simply want a groomed chihuahua. Why do I need to consult a wizard to get back a groomed chihuahua?

A magician should never reveal his secrets, but this I do share.
.sort() returns a SortedRange [1] that encapsulates the range.
The trick is to use .release() to release the controlled range and return it, e.g.

import std.algorithm : sort;
auto keys = aa.keys.sort().release;

[1] https://dlang.org/phobos/std_range.html#SortedRange

Reply via email to