Use simpler query for getSortedVersions

The old one read and parsed JSON blobs from sqlite instead of just using
pre-existing columns.