Sorting

We allow users to sort with the following criteria for all models:

  • Sort by highest rating to lowest rating
  • Sort by lowest rating to highest rating
  • Sort alphabetically in ascending order
  • Sort alphabetically in descending order

All of the sorting is implemented on the back-end using the sqlalchemy query.order_by method. The front-end merely displays the data retrieved from the API. To sort things, we simply append parameters to the API request just like the filtering. It is also possible to do a combination of both sorting and filtering.

For instance, if you want to sort all the restaurants by rating in descending order, use the following API request:

api.tacoboutaustin.me/restaurants?order_by=rating&order=desc

If you want to sort all restaurants with a rating of at least 4 alphabetically in ascending order, use the following request:

api.tacoboutaustin.me/restaurants?order_by=name&order=asc&rating=4

results matching ""

    No results matching ""