How to sort by a sum

I.m struggling with sorting by a sum value. I’ve created a server action that generates a sum for “wins” by a team at a certian track but I cannot get the table to sort by the sum value.

https://www.pasprintseries.com/TrackDetails.php?id=Port%20Royal%20Speedway&sort=wins&dir=desc

By the look of them, those are Wapper generated bootstrap tables? If so why not go a stage further and add sortable headers so the viewers can choose the order?

Alternatively in app connect sorting the query returned like this may work when used as the data source for the table. (never tried this, just a suggestion)

so try:

conn.data.query.sort(sum) rather than conn.data.query

At present I don’t think it is possible to sort a server action by an alias or calculated field in the query manager, it needs manually changes to the server action jquery

Thanks Ben.

Yes it’s a generated table
I tried adding the sort-able headers but they come up random. I’ll have to try to figure out your other suggestion.

I would really appreciate it if sorting by aggregate could be added. This has come up in my work a number of times. I’m currently manually updating our point standings on a weekly basis to get them to sort by totals.