In many cases, the web engine that generates data tables (html) is close-sourced and you cannot sort those tables. It is not because the engine does not have a mechanism to sort data. It's just that its behaviors does not satisfy your need. For example, the PowerSchool customization engine.
In PowerSchool, I can output a table of lunch balance information of a student using this template syntax:
Did you see the > (greater than) sign? It says that the table will sort by the date and time columns in ascending order. What I want is to make it sort date and time in descending order. So I tried to replace the > with the < (less than) hoping that it would reverse the sorting order. But it turned out all the balance data was messed up. The thing is it calculates balance data on the go (up to the current transaction) and depends on date & time when you input transaction data into the system (or the order of the records that matters) and the beginning balance of the student.