Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. from collection import collection
  2. import sys, tty, termios
  3. def getch():
  4.     fd = sys.stdin.fileno()
  5.     old_settings = termios.tcgetattr(fd)
  6.     try:
  7.         tty.setraw(sys.stdin.fileno())
  8.         ch = sys.stdin.read(1)
  9.     finally:
  10.         termios.tcsetattr(fd,termios.TCSADRAIN, old_settings)
  11.     return ch
  12. def sorting(x,y):
  13.     while True:
  14.         print "larger is j: "+str(x)+" k: "+str(y)
  15.         r = getch()
  16.         if r == "j":
  17.             return +1
  18.         elif r == "k":
  19.             return -1
  20. print sorted(collection,cmp=sorting)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement