adrianpierce commited on
Commit
9bb70c7
·
1 Parent(s): 26d9a53

Update pages/2_Saved_Recipes.py

Browse files
Files changed (1) hide show
  1. pages/2_Saved_Recipes.py +5 -1
pages/2_Saved_Recipes.py CHANGED
@@ -22,10 +22,14 @@ cols = st.columns([4, 1])
22
  with cols[0]:
23
  user_search = st.text_input("Search Recipes", value="")
24
  with cols[1]:
25
- user_sort = st.selectbox("Sort", ('A-Z', 'Z-A', 'Random'))
26
  st.write("") # just some space
27
 
28
  recipes_filtered = [x for x in recipes if user_search.lower() in x['name'].lower()]
 
 
 
 
29
  if user_sort == 'A-Z':
30
  recipes_filtered.sort(key=lambda x: x['name'])
31
  elif user_sort == 'Z-A':
 
22
  with cols[0]:
23
  user_search = st.text_input("Search Recipes", value="")
24
  with cols[1]:
25
+ user_sort = st.selectbox("Sort", ('Recent', 'Oldest', 'A-Z', 'Z-A', 'Random'))
26
  st.write("") # just some space
27
 
28
  recipes_filtered = [x for x in recipes if user_search.lower() in x['name'].lower()]
29
+ if user_sort == 'Recent':
30
+ recipes_filtered.sort(key=lambda x: x['timestamp'])
31
+ if user_sort == 'Oldest':
32
+ recipes_filtered.sort(key=lambda x: x['timestamp'], reverse=True)
33
  if user_sort == 'A-Z':
34
  recipes_filtered.sort(key=lambda x: x['name'])
35
  elif user_sort == 'Z-A':