Skip to content

pope/version_sorter

 
 

Repository files navigation

Version sorter

Fast sorting of strings representing version numbers.

require 'version_sorter'

versions = ["1.0.9", "2.0", "1.0.10", "1.0.3", "2.0.pre"]

VersionSorter.sort(versions)
#=> 1.0.3
#=> 1.0.9
#=> 1.0.10
#=> 2.0.pre
#=> 2.0

You can also sort arrays of arbitrary objects by providing a block.

VersionSorter.sort(tags) { |tag| tag.name }

Library API:

VersionSorter.sort(versions)   #=> sorted array
VersionSorter.rsort(versions)  #=> reverse sorted array

VersionSorter.sort!(versions)  # sort array in place
VersionSorter.rsort!(versions) # reverse sort array in place

http://github.com/blog/521-speedy-version-sorting

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 52.7%
  • Other 22.6%
  • Ruby 19.0%
  • Shell 5.5%
  • Vim Script 0.2%