Ah ok, got it!
In this case, you’ll need 2 variables:
- one to change the sort from ascending to descending alphabetical order every time the user clicks on the sort icon
- one to change the name of the field you’re sorting through depending on which sort icon the user clicked on
In your project, I’ve named these variables:
- sortOrder
- filterName
Both are string variables that are empty by default.
Since you have 2 variables you want to change when the user clicks on each sort icon, you’ll need 2 actions in the workflows that trigger when the user clicks on a sort icon:
-
the first action will change the filterName variable to match the field in your database that you want to filter
-
the second action will change the sortOrder variable each time the user clicks
In the screenshots, we’ve done this for the sort icon related to the “First Name” field. You would need to repeat the same action on each sort icon. The only thing that would change is the text you put in the first action.
Finally, you would change the formula on the Collection List:
- the array is still the collection data
- we want to sort it in ascending or descending order (changes every time the user clicks on the icon)
- by the field defined in the filterName variable (changes based on which icon the user clicks on)
If you’d like to check it out, I’ve set it up in the test page of your project