Sort packed grammar in memory, instead of on disk

to prevent running out of storage during grammar packing.
Sort uses the same amount of memory as reserved for the grammar packer