fixed bug in pgorder with inversion