New answers tagged sorting
To produce your desired output, you can simply: SELECT id, version FROM versions ORDER BY string_to_array(version, '.')::int; One can cast a whole text array to an integer array (to sort 9 before 10). One can ORDER BY array types. This is the same as ordering by each of the elements. SQL Fiddle (reusing @a_horse's fiddle, thanks!)
create extension semver; select id, version from SoftwareReleases order by version::semver; http://www.pgxn.org/dist/semver/doc/semver.html
select id, name, v as major_version, v as minor_version, v as patch_level from ( select id, name, string_to_array(version, '.') as v from versions ) t order by v::int desc, v::int desc, v::int desc; SQLFiddle: http://sqlfiddle.com/#!15/c9acb/1 If you expect more elements in the ...
Top 50 recent answers are included