[Issue 24048] Can't sort after filter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 19 07:20:32 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=24048

--- Comment #4 from Grim Maple <grimmaple95 at gmail.com> ---
(In reply to Grim Maple from comment #3)
> (In reply to Nick Treleaven from comment #1)
> > filter returns an input range.
> > sort requires a random access range and works in place and has good time
> > complexity.
> > How do you want to sort an input range?
> 
> As a user, I shouldn't care about what `filter` returns. I should care about
> getting a filtered & sorted array/range.
> 
> As for `sort`, in my user opinion, if it can't do its job "in place", then
> it could as much do it out-of-place, because this code
> 
> ```
> auto a = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5];
> a.sort!((x, y) => x > y).writeln;
> ```
> 
> fails to compile just as much, and it's staright up inconvenient

I meant to change `auto a` to `immutable a`. Then it won't compile, but should

--


More information about the Digitalmars-d-bugs mailing list