fixed the sorting of pgdata