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

```python
move_zeros([False,1,0,1,2,0,1,3,"a"]) # returns[False,1,1,2,1,3,"a",0,0]
```

Difficulty: EASY
Tags: Sorting

Data structures
Skill types: Sorting

Data structures

Starter code:
def move_zeros(array):
	

Solutions:
def move_zeros(arr):
	l = [i for i in arr if isinstance(i, bool) or i != 0]
	return l + [0] * (len(arr) - len(l))


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


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


def move_zeros(array):
	newarr = []
	zeroarr = []
	for item in array:
		if item != 0 or type(item) == bool:
			newarr.append(item)
		else:
			zeroarr.append(item)
	newarr.extend(zeroarr)
	return newarr


def move_zeros(array):
	return [a for a in array if isinstance(a, bool) or a != 0] + [a for a in array if not isinstance(a, bool) and a == 0]


def move_zeros(array):
	a = list(filter(lambda x: x != 0 or type(x) is bool, array))
	return a + [0] * (len(array) - len(a))


def move_zeros(array):
	return [x for x in array if x != 0 or x is False] + [x for x in array if x == 0 and (not x is False)]


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


def move_zeros(array):
	temp = []
	for e in array[::-1]:
		if type(e) in (int, float, complex) and e == 0:
			temp.append(0)
		else:
			temp.insert(0, e)
	array = temp
	return array


def move_zeros(array):
	without_zeros = list(filter(lambda n: not n == 0 or n is False, array))
	for i in range(len(array) - len(without_zeros)):
		without_zeros.append(0)
	return without_zeros


def move_zeros(array):
	a_len = len(array)
	array = [v for v in array if type(v) is bool or v != 0]
	array.extend([0] * (a_len - len(array)))
	return array


def move_zeros(array):
	a = []
	b = []
	for v in array:
		if type(v) in [float, int] and v == 0:
			b.append(0)
		else:
			a.append(v)
	return a + b


move_zeros = lambda arr: [i for i in arr if str(i) == 'False' or i != 0] + [_ for _ in arr if str(_) != 'False' and _ == 0]


def move_zeros(array):
	new_list = []
	c = 0
	for item in array:
		if item != 0 or type(item) == bool:
			new_list.append(item)
		else:
			c += 1
	i = 0
	while i < c:
		new_list.append(0)
		i += 1
	return new_list


def move_zeros(array):
	new_array = []
	for check in array:
		if check != 0 or isinstance(check, bool):
			new_array.append(check)
	for cnt in range(abs(len(new_array) - len(array))):
		new_array.append(0)
	return new_array


def move_zeros(array):
	strs = []
	array1 = array.copy()
	for i in array1:
		if isinstance(i, str):
			strs.append(i)
			array1[array1.index(i)] = ' '
	for i in array1:
		array1[array1.index(i)] = str(array1[array1.index(i)])
	for i in array1:
		if i == '0' or i == '0.0':
			array1.remove(i)
			array1.append('0')
	for i in array1:
		if i != ' ':
			array1[array1.index(i)] = eval(array1[array1.index(i)])

	def insf():
		v = 0
		while v < len(strs):
			v += 1
			yield v
	n = insf()
	for i in array1:
		if i == ' ':
			array1[array1.index(i)] = strs[next(n) - 1]
	return array1


def move_zeros(array):
	zeros = 0
	new_arr = []
	for ele in array:
		if type(ele).__name__ != 'str' and str(ele) in '0.0':
			zeros += 1
		else:
			new_arr += [ele]
	return new_arr + [0] * zeros