How to sort on a dynamic column of a table?

Hi, I dynamically calculate a column of a table (“Average”), and then I would like to sort it by the new field. How do you do it with javascript?

Thanks at all
Claudio