sort data returned by database (server side)