Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collection import collection
- import sys, tty, termios
- def getch():
- fd = sys.stdin.fileno()
- old_settings = termios.tcgetattr(fd)
- try:
- tty.setraw(sys.stdin.fileno())
- ch = sys.stdin.read(1)
- finally:
- termios.tcsetattr(fd,termios.TCSADRAIN, old_settings)
- return ch
- def sorting(x,y):
- while True:
- print "larger is j: "+str(x)+" k: "+str(y)
- r = getch()
- if r == "j":
- return +1
- elif r == "k":
- return -1
- print sorted(collection,cmp=sorting)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement