On 28/05/13 11:50, bearophile wrote:
Peter Williams:
Are the () necessary on sort?
If you don't use () I think you call the slower, not flexible and buggy
built-in sort. I think it's already deprecated. Maybe I am wrong...
Ah. Does that mean that import.algorithms is need to use sort()?
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.
I don't fully understand.
I'm assuming here that it's safe to call sort() on the .keys property of
the dynamic array. This enables me to go:
foreach (key; aa.keys.sort()) {...}
instead of the much more complex code I'm currently writing which gets
the keys, sorts them and then uses them in the foreach. I had actually
written a generic function to do all of that but now find all the work
was unnecessary :-).
As I learn more about D I'm finding I can go back and simplify a lot of
my code. I'm going to reread Andrei's book to see what I missed the
first time.
Peter
PS I think I need to read more about component programming as I'm
beginning to suspect I don't understand it fully.