Sortable Semantic Version Strings in Rails (part 1)

Sometimes we need to sort string values that aren’t lexicographically sortable. For example, a list of Semantic Version strings like 1.0.0-rc1, 1.2.4, 1.1.0-beta and 2.0.0.