Sort packages by version, and fix syntax for category sort