More on "Component Programming"

Peter Williams pwil3058 at bigpond.net.au
Mon May 27 18:30:55 PDT 2013


On 28/05/13 10:37, bearophile wrote:
>>     .map!(words => words
>>                    .classify!q{ a
>>                                 .dup
>>                                 .representation
>>                                 .sort()
>>                                 .release
>
> Also, let's kill the built-in sort already :-)
>

But I just found it and started using it. :-)

I was contemplating writing my own sort function as the ones in 
std.algorithm didn't meet my needs (or using them was too messy) until I 
discovered this feature.

Are the () necessary on sort?  I found:

auto sorted_array = an_array.dup.sort;

worked.

Peter
PS Now I've found this I can go back and simplify all the code where I 
iterated over associative arrays in key order by getting the keys and 
the sorting them separately.
PPS Every time I discover one of these features I like D even more.


More information about the Digitalmars-d mailing list