sort batch_ids by descending order
This commit is contained in:
committed by
Michael McGuinness
parent
dda118a919
commit
d8aa2c8354
+21
-18
@@ -102,36 +102,39 @@ if client:
|
||||
# 'batch_160524071331', 'batch_200524213550', 'batch_250424112237', 'batch_280524120530', 'batch_280524121721', 'batch_280524144222',
|
||||
# 'batch_290524123926', 'batch_290524164044', 'batch_310524102029', 'batch_310524124050', 'batch_310524162346', 'batch_310524162631']
|
||||
|
||||
if 'sorted_list' not in st.session_state:
|
||||
st.session_state.sorted_list = batch_list
|
||||
|
||||
def sort_list(ex_list, sort_by, order):
|
||||
if sort_by == 'Alphabetical':
|
||||
ex_list = sorted(ex_list, reverse=(order == 'Descending'))
|
||||
elif sort_by == 'Create Date':
|
||||
ex_list = ex_list if order == 'Ascending' else list(reversed(ex_list))
|
||||
#Select Box for Applying Different Sort for the Batch List
|
||||
|
||||
return ex_list
|
||||
# if 'sorted_list' not in st.session_state:
|
||||
# st.session_state.sorted_list = batch_list
|
||||
|
||||
col1, col2, col3, col4 = st.columns([0.5, 0.5, 0.5, 0.5])
|
||||
# def sort_list(ex_list, sort_by, order):
|
||||
# if sort_by == 'Alphabetical':
|
||||
# ex_list = sorted(ex_list, reverse=(order == 'Descending'))
|
||||
# elif sort_by == 'Create Date':
|
||||
# ex_list = ex_list if order == 'Ascending' else list(reversed(ex_list))
|
||||
|
||||
# return ex_list
|
||||
|
||||
# col1, col2, col3, col4 = st.columns([0.5, 0.5, 0.5, 0.5])
|
||||
|
||||
|
||||
with col1:
|
||||
sort_by = st.radio("**Sort Batch_IDs**", ('Alphabetical', 'Create Date'))
|
||||
# with col1:
|
||||
# sort_by = st.radio("**Sort Batch_IDs**", ('Alphabetical', 'Create Date'))
|
||||
|
||||
with col2:
|
||||
order = st.radio('', ('Ascending','Descending'))
|
||||
# with col2:
|
||||
# order = st.radio('', ('Ascending','Descending'))
|
||||
|
||||
with col3:
|
||||
add_vertical_space(2)
|
||||
if st.button('Apply'):
|
||||
st.session_state.sorted_list = sort_list(batch_list, sort_by, order)
|
||||
# with col3:
|
||||
# add_vertical_space(2)
|
||||
# if st.button('Apply'):
|
||||
# st.session_state.sorted_list = sort_list(batch_list, sort_by, order)
|
||||
|
||||
path_row = st.columns([0.1, 0.8])
|
||||
with path_row[0]:
|
||||
st.write("**Batch ID**")
|
||||
with path_row[1]:
|
||||
batch_id = st.selectbox('**Batch ID**', st.session_state.sorted_list, label_visibility = "collapsed", index = None)
|
||||
batch_id = st.selectbox('**Batch ID**', reversed(batch_list) , label_visibility = "collapsed", index = None)
|
||||
|
||||
if not batch_id:
|
||||
batch_id = "None"
|
||||
|
||||
Reference in New Issue
Block a user