def SortArrayIntoZigZagPattern(lst) :
small = True
size = len(lst)
i = 0
while (i <= size - 2) :
if (small) :
if (lst[i] > lst[i + 1]) :
lst[i], lst[i + 1] = lst[i + 1], lst[i]
else :
if (lst[i] < lst[i + 1]) :
lst[i], lst[i + 1] = lst[i + 1], lst[i]
small = not small
i += 1
# a < b > c < d > e < f > g...
# 3 < 5 > 1 < 9 > 6 < 7 > 2 < 4
lst = [3, 5, 1, 7, 9, 6, 4, 2]
SortArrayIntoZigZagPattern(lst)
print(lst)
'''
run:
[3, 5, 1, 9, 6, 7, 2, 4]
'''