def CreateSortKeyPrefix(timestamp, randomness=True, reverse=False):
 assert (timestamp < (1L << 32)), timestamp
 if reverse:
  timestamp = (((1L << 32) - int(timestamp)) - 1)
 if randomness:
  random_bits = (random.getrandbits(16) & 65535)
 else:
  random_bits = 0
 return base64hex.B64HexEncode(struct.pack('>IH', int(timestamp), random_bits))

def CreateSortKeyPrefix ( timestamp , randomness = True , reverse = False ) : assert ( timestamp < ( 1 L << 32 ) ) , timestamp if reverse : timestamp = ( ( ( 1 L << 32 ) - int ( timestamp ) ) - 1 ) if randomness : random_bits = ( random . getrandbits ( 16 ) & 65535 ) else : random_bits = 0 return base64hex . B64HexEncode ( struct . pack ( '>IH' , int ( timestamp ) , random_bits ) )
returns a sort key which will sort by timestamp .