Preferred version sort

I found a problem where using "%" in the PREFERRED_VERSION field sometimes product unexpected behavior.  I expected this to always find the latest version of the package in the "%" range, but this did not always happen.  So, to improve this, I added this code to ensure that the "%" range consistently found the latest version that matched the search criteria.