def _GuessOrders(filters, orders):
 orders = orders[:]
 if (not orders):
  for filter_pb in filters:
   if (filter_pb.op() != datastore_pb.Query_Filter.EQUAL):
    order = datastore_pb.Query_Order()
    order.set_property(filter_pb.property(0).name())
    orders.append(order)
    break
 exists_props = (filter_pb.property(0).name() for filter_pb in filters if (filter_pb.op() == datastore_pb.Query_Filter.EXISTS))
 for prop in sorted(exists_props):
  order = datastore_pb.Query_Order()
  order.set_property(prop)
  orders.append(order)
 if ((not orders) or (orders[(-1)].property() != '__key__')):
  order = datastore_pb.Query_Order()
  order.set_property('__key__')
  orders.append(order)
 return orders

def _GuessOrders ( filters , orders ) : orders = orders [ : ] if ( not orders ) : for filter_pb in filters : if ( filter_pb . op ( ) != datastore_pb . Query_Filter . EQUAL ) : order = datastore_pb . Query_Order ( ) order . set_property ( filter_pb . property ( 0 ) . name ( ) ) orders . append ( order ) break exists_props = ( filter_pb . property ( 0 ) . name ( ) for filter_pb in filters if ( filter_pb . op ( ) == datastore_pb . Query_Filter . EXISTS ) ) for prop in sorted ( exists_props ) : order = datastore_pb . Query_Order ( ) order . set_property ( prop ) orders . append ( order ) if ( ( not orders ) or ( orders [ ( - 1 ) ] . property ( ) != '__key__' ) ) : order = datastore_pb . Query_Order ( ) order . set_property ( '__key__' ) orders . append ( order ) return orders
guess any implicit ordering .