Keep selected table rows after sort change

How do I maintain the selected items of a table after the sort order has changed from a column click? The examples I have lookd at so far keep the selected row positions while the data rows that were selected before the sort change are now de-selected. I’m trying to get the same behavior as Finder windows. Any clues or snippets would be most appreciated.