added the sorting functionality for packages