sort!("...") with template function?

Andrea Fontana nospam at example.org
Mon Feb 25 12:47:50 UTC 2019


On Monday, 25 February 2019 at 12:37:31 UTC, Vladimirs Nordholm 
wrote:
> Hello.
>
> I wish to sort an array by calling a template function on a 
> struct. In essence I want to do
>
>     foos.sort!("a.get!Dummy < b.get!Dummy");
>
> but I get the error message
>
>     
> /dlang/dmd/linux/bin64/../../src/phobos/std/functional.d-mixin-215(215): Error: undefined identifier Dummy
>
> Is there anyway I can get `sort` to recognise my Dummy type?
>
> Example: https://run.dlang.io/is/9zDfdd

Maybe:
foos.sort!((a,b) => a.get!Dummy < b.get!Dummy);

Andrea


More information about the Digitalmars-d-learn mailing list