added sort by to page sql
sets negative coordinates to 1