Is it possible to add sorting to this dataframe generated using below code please:
import pandas as pd
# Sample DataFrame
df = pd.DataFrame({
'Name': ['Alice', 'Bob', 'Charlie'],
'Age': [24, 30, 22],
'Score': [88, 92, 85]
})
# Function to style DataFrame cells with HTML based on the 'Score' value
def apply_callout_html(val):
if val > 90:
return f'<div style="background-color:#e8f9ee;color:#177233;padding:5px;border-radius:5px;">{val}</div>'
elif val < 85:
return f'<div style="background-color:#ffecec;color:#7d353b;padding:5px;border-radius:5px;">{val}</div>'
else:
return f'<div>{val}</div>'
# Apply callouts to the 'Score' column
df['Score'] = df['Score'].apply(apply_callout_html)
# Convert DataFrame to HTML with escape=False to allow HTML elements
df_html = df.to_html(escape=False)
# Display the styled DataFrame in Streamlit
st.markdown(df_html, unsafe_allow_html=True)```