fixed bug: in sorting sql query for sorting by current magnitudes