Sorting after map

Lutger lutger.blijdestijn at
Wed Oct 20 00:29:41 PDT 2010

clueless wrote:

> Hi. I want to have a sorted result of map-function, that is (in
> pseudocode):
> sorted(map!(fun)(arr))
> How can I do that? I have tried something like:
> auto s = map!(fun)(arr);
> //sort(s);
> //sort(s[]);
> //sort(s.dup);
> writeln(s);
> but without success.
> Thanks in advance.

Hi, I'm not sure if it is supposed to work or not. sort is inplace but map   
does not offer opIndexAssign which sort needs. You can circumvent it by 
creating an array of the map:

import std.array;

auto s = array(map!fun(arr));

More information about the Digitalmars-d-learn mailing list