in reply to move all 0s in an array to the beginning keeping other elements order same

Here's another way to do it if all the false values are just zero:

my $size = @array; @array = grep {$_} @array; unshift @array, (0) x ($size - @array);
  • Comment on Re: move all 0s in an array to the beginning keeping other elements order same
  • Download Code