sort by calculated column

How to sort records by a calculated column.

e.g {score} s a user defined feld not found in db.

OnLoadRecord:

$check_sql = “SELECT SUM(mark_index) from tbl_course WHERE student_id = ‘{student_id}’”;
sc_lookup(rs, $check_sql);

$temp = {rs[0][0]};

{score} = round($temp / 100);

Now how to sort by this fied?

If you need to be able to sort upon a calculated field then try to do this as a new field within the sql statement. Calculated fields are created on a onload event. So they exist only for a short time. That’s why there’s no sort as this afaik is done by altering the order by on the sql select. Perhaps a bit cryptic but I hope you get the idea.