restored grammar sorting to grammar packer