add sorting by primary key, needed for postgres, fix #320