Factor out the release sorting function.