Is PortalSortValue a field with global storage?
another option, if you're using FM11 is to use tabs. You can make as many tabs as you need for the different sort options and set a portal on each one with the sort/filter options you want. Then name the tabs something that makes sense for each applicable sort order, clicking on each of those names brings that tab/protal to the front.
your question presented the obvious problem.
using set field was doing just that, for the very first record in the table, which was sorted by last name and happened to meet my search criteria.
so, to the user (or the stupid developer) it appeared to be broken.
i can use either replace field contents for the found set, or perhaps even a variable? $$PortalSortValue to get the portal to sort.
for now i am using replace field just because it works, but i think that's likely creating a lot of calc work for no reason.
Use a global field for PortalSortValue so that you only have to set the value once. Then use Refresh Window [Flush cached Join Results] to force the portal to update and display the records in the new sort order.
Here's a demo file that sorts by a text, date or number (integer) field based on user selected options and also sorts in ascending or descending order. This demo file was made possible from info I've read in the FileMaker 11 Training Series manual.