-def sortklings():
- # sort Klingons by distance from us
- # The author liked bubble sort. So we will use it. :-(
- if game.nenhere-(thing==game.quadrant)-(game.tholian!=None) < 2:
- return
- while True:
- sw = False
- for j in range(game.nenhere-1):
- if game.kdist[j] > game.kdist[j+1]:
- sw = True
- t = game.kdist[j]
- game.kdist[j] = game.kdist[j+1]
- game.kdist[j+1] = t
- t = game.kavgd[j]
- game.kavgd[j] = game.kavgd[j+1]
- game.kavgd[j+1] = t
- k = game.ks[j].x
- game.ks[j].x = game.ks[j+1].x
- game.ks[j+1].x = k
- k = game.ks[j].y
- game.ks[j].y = game.ks[j+1].y
- game.ks[j+1].y = k
- t = game.kpower[j]
- game.kpower[j] = game.kpower[j+1]
- game.kpower[j+1] = t
- if not sw:
- break
-