On Saturday, 21 December 2013 at 02:52:00 UTC, bearophile wrote:
Do not forget to add the () after the sort, otherwise you call the deprecated, buggy and slow built-in sort.

reverse is another deprecated built-in, so use "retro".

The first "if" is not much useful, trying to sort an empty array will not wast much time.

foreach (i; index.sort().retro)
    a = a.remove(i);

In alternative you can also invert the sorting cmp (untested):

foreach (i; index.sort!q{a > b})
    a = a.remove(i);

Thanks, that looks like the cleanest solution so far! So (I guess) it will not cause index.length reallocations by just moving the elements in-place and then returning a slice?

P.S. I wonder where would one learn about the deprecated sort and reverse if not from this forum? I followed the official docs and there's nothing about these properties being deprecated... yet another spot where a compiler warning would be appropriate?

Reply via email to