Sorting via query for list.pl