There is an array

ar = [1,4,5,7,3,6,2,0,9,0,10,0,0] 

Sort it

 ar.sort(function(a,b){ return ab; }) 

We get 0,0,0,0,1,2,3,4,5,6,7,9,10

Question: how to sort the array so that you can get 1,2,3,4,5,6,7,9,10,0,0,0,0,0

    1 answer 1

    So:

     function(a,b){ return a*b==0?ba:ab; } 
    • Thanks, works as it should - Alexander Petrov