Check from ExtraFields in getSortTableClauseForIds

if no extrafields are on the many_many relationship error generated same fix as chillu on getSortTable