While ad_table and friends supports sorting, it involves a new request to the server with the associated delay even though the data to reorder is already available in the user's browser.
The following "trick" allows you to sort the data in place. It is by no means a replacement for SQL sorting, but can be used as a light-weight alternative on clients that have JS enabled. It only makes sense to use it when there's no pagination involved (i.e. all the rows are on the same page) or when the query used to extract the data is expensive.
One of the nice things about this is how trivial it is to make use of it.