code: def SortBy(*qs):
      
  
      sort = []
      for q in qs:
          if q._path.endswith('.desc'):
              sort.append((q._path[:-5], DESCENDING))
          else:
              sort.append((q._path, ASCENDING))
      return sort
docs: Convert a list of Q objects into list of sort instructions