def parse_sorted_query(model_cls, parts, prefixes={}, query_cls=query.AndQuery):
 query_parts = []
 sort_parts = []
 for part in parts:
  if (part.endswith((u'+', u'-')) and (u':' not in part)):
   sort_parts.append(part)
  else:
   query_parts.append(part)
 q = query_from_strings(query_cls, model_cls, prefixes, query_parts)
 s = sort_from_strings(model_cls, sort_parts)
 return (q, s)

def parse_sorted_query ( model_cls , parts , prefixes = { } , query_cls = query . AndQuery ) : query_parts = [ ] sort_parts = [ ] for part in parts : if ( part . endswith ( ( u'+' , u'-' ) ) and ( u':' not in part ) ) : sort_parts . append ( part ) else : query_parts . append ( part ) q = query_from_strings ( query_cls , model_cls , prefixes , query_parts ) s = sort_from_strings ( model_cls , sort_parts ) return ( q , s )
given a list of strings .