[Issue 24048] Can't sort after filter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 18 19:23:35 UTC 2023


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

--- Comment #3 from Grim Maple <grimmaple95 at gmail.com> ---
(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

--


More information about the Digitalmars-d-bugs mailing list