Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by roboticus (Chancellor)
on May 01, 2014 at 21:54 UTC ( [id://1084693]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @new_array=();
    for my $i (@array) {
    ...
          unshift @new_array, $i;
       }
    }
    
  2. or download this
    my @new_array = (
        grep( { ! $_ } @array),
        grep( { $_ } @array)
    );
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1084693]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-25 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found