Hi @Anonymous,
You can use the Sort or SortByColumns functions. I prefer the SortByColumns function but they are very similar
The syntax is SortByColumns(myDataSource,"ColumnName", OrderToSortBy)
If you wanted a sort button similar to sample screens, they work by using a Variable which, when you click on the sort button, inverts the value from true to false or vice versa.
1. Create a sort button. You can use an icon, button, label -- anything you want. Set it's OnSelect property to:
UpdateContext({SortDescending:!SortDescending})
Note the ! reverses the boolean value, so you are creating a Variable with the name SortDescending and setting the value of that variable to the opposite of what it is currently.
2. Create your Gallery. The Gallery's Data Source should point to your data source, and the Items property should be something like:
SortByColumns(myDataSource,"ColumnName", If(SortDescending,Descending,Ascending))
The way this works is that the Variable SortDescending is either true or false, so the If statement determines whether to sort by Descending (If true) or Ascending (If false). If you want the Gallery to display by Descending (new - old) by default, have the OnVisible property of that screen declare the Variable as true with:
UpdateContext({SortDescending:true})
I think this mostly covers your issue. Is there anything else that I can help with?