results: implement sorting of tables
This implements some basic sorting for the tables displayed in the result templates. Sorting is done by clicking on a table column header to sort the table by values in the column. Clicking on the header again will change the sort order (asc vs desc).