Added reverse-sort command, other changes.

Fixed crash on chest-sort.

Hopefully stabilized sort for stacks of matching items, different rarities.