On 04/12/2017 05:42 PM, Shawn H Corey wrote:
On Wed, 12 Apr 2017 16:19:32 -0400
Uri Guttman <u...@stemsystems.com> wrote:
my @array;
for my $index (reverse sort @indices) {
sort defaults to a lexical sort which won't work well on integers
with more than 2 digits.
and why are you sorting and reversing the indexes? i don't think that
will help make the splice more efficient if any of the indexes are
not at the end of the array.
If you're going to splice, do it from the highest index to the lowest.
Otherwise the splice will shift the end of the array down, which messes
up the indexing.
but if the splice is not at the end of the array it doesn't save much.
you still have to shift down multiple elements on each call to splice.
maybe you shift down fewer as there are now fewer elements up top.
anyhow, i was somewhat surprised to see splice was the fastest method. i
feel there is something odd and maybe with a larger data set, that
wouldn't be the case.
uri
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/