Skip to content

Latest commit

 

History

History
33 lines (18 loc) · 467 Bytes

Moving_Zeros_To_The_End.md

File metadata and controls

33 lines (18 loc) · 467 Bytes

CodeWars Python Solutions


Moving Zeros To The End

Write an algorithm that takes an array and moves all of the zeros to the end, preserving the order of the other elements.


Given Code

def move_zeros(array):
    pass

Solution

def move_zeros(array):
    return sorted(array, key=lambda x: x==0 and type(x) is not bool)

See on CodeWars.com