Improve sorting of plugin packages, fixes #3109, refs #2972