sort the column so id is the first column returned
fix the check permission query