www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24048] New: Can't sort after filter

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

          Issue ID: 24048
           Summary: Can't sort after filter
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: grimmaple95 gmail.com

This code fails to compile

```
auto a = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5];
a.filter!(x => x > 2).sort!((x, y) => x > y).writeln;
```

because you can't sort over filter result. Adding `.array` before `.sort`
"fixes" the problem. Probably, it should work without the `array` inbetween

--
Jul 18 2023