Yes. Here's an easy one to implement
A Portal's sort order is static not dynamic. Any scripts to dynamically sort a portal manage to do so in spite of that limitation:
Put several copies of a portal, each with different sort orders specified, into different panels of a slide or tab control. Give each panel an object name and your script can use go to object to bring different panels to the front. This enclosing control can be invisible, or you can use the tabs of a tab control to be the method the user uses to select a sort order and then no script is needed.
It's also possible to set up a complex, unstored calculation field that returns a text result type, that uses a Case statement to reference data in different fields depending on the value specified in a global field or variable. Number and date fields have to be formatted into a text result that sorts correctly even when the values are text--such as "padding" number values with leading zeroes so this is a complex undertaking and can result in a very slow to update portal if you have a lot of records due to the field being unstored. Your portal would specify this field as its sort field.
Hadn't used the tab control feature. A simple and satisfactory solution.
I may need to sort the portal on a related, displayed field. Will investigate Steve Martino's reference to see if that is feasible. Or can someone tell me I'm chasing windmills on that one?
You can add a calculation field in the portal's table that references the related record's field and then sort on the calculation field.
Duh. I had in my mind that it needed to be indexable.
I'm good to go.