Ruby on Rails 希望内容按版本号(semver)排序

Version sort (with alphas, betas, etc.) in ruby
更新于: 2021-11-19 14:43:16
ar = ['10.0.0b12', '10.0.0b3', '10.0.0a2', '9.0.10', '9.0.3']

p ar.sort_by { |v| Gem::Version.new(v) }
# => ["9.0.3", "9.0.10", "10.0.0a2", "10.0.0b3", "10.0.0b12"]