Skip to content

Commit

Permalink
feat: Sort restaurant sausage availability by date
Browse files Browse the repository at this point in the history
The code changes in this commit modify the `unicafe_global_sausagesearch` function in `app.py` to sort the restaurant sausage availability by date. The function now creates a list of restaurants and dates as tuples, sorts them by date, and returns the sorted dictionary of restaurants and dates.
  • Loading branch information
lamtonylam committed Aug 21, 2024
1 parent 2b0fc7c commit 8be22bd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,18 @@ def unicafe_global_sausagesearch():
if sausage_dates:
restaurant_sausage_dict[restaurant] = sausage_dates

return restaurant_sausage_dict
# make a list of restaurants and dates as tuples
sortedRestaurantsDate = list(restaurant_sausage_dict.items())

# func to return the pure date of sausage availability of a restaurant
def returndate(item):
return item[1][0][3:8]

# sort the items by date
sortedRestaurantsDate.sort(key=returndate)
sortedRestaurantsDate = dict(sortedRestaurantsDate)

return sortedRestaurantsDate


@app.route("/")
Expand Down

0 comments on commit 8be22bd

Please sign in to comment.