Skip to content

Instantly share code, notes, and snippets.

@ajilo297
Last active September 17, 2017 17:23
Show Gist options
  • Save ajilo297/9b8e41541fcafcbb730e24505e5073db to your computer and use it in GitHub Desktop.
Save ajilo297/9b8e41541fcafcbb730e24505e5073db to your computer and use it in GitHub Desktop.
Ordering List in Python
a = [0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1]
a = [0] * a.count(0) + [1] * a.count(1)
@ajoyoommen
Copy link

input = [0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1]

countZero = input.count(0)
countOne = input.count(1)

input = [0] * countZero + [1] * countOne

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment