Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 18, 2023 [Issue 24048] Can't sort after filter | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24048 Nick Treleaven <nick@geany.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@geany.org --- Comment #1 from Nick Treleaven <nick@geany.org> --- 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? -- |
July 18, 2023 [Issue 24048] Can't sort after filter | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24048 --- Comment #2 from anonymous4 <dfj1esp02@sneakemail.com> --- It would do inputRange.array.sort!predicate, that's how sort usually works on input ranges. -- |
July 18, 2023 [Issue 24048] Can't sort after filter | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24048 --- Comment #3 from Grim Maple <grimmaple95@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 -- |
July 19, 2023 [Issue 24048] Can't sort after filter | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24048 --- Comment #4 from Grim Maple <grimmaple95@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 -- |
Copyright © 1999-2021 by the D Language Foundation