You could use the rpm query tag "BUILDTIME", if it is accurate, to compare the two. I don't have a system with rpm at my disposal, so I can't check, but major packages like those should have consistent build times. It would be worth checking out.
The other option (which might be painful in bash) is to use regexes to pull out each part of the version and compare it. I would look at this for a start: http://www.linuxjournal.com/content/bash-regular-expressions
Sorry I can't give you a more full solution.