Module: VersionSorter
Instance Method Summary collapse
Instance Method Details
#rsort(list) ⇒ Object
27 28 29 |
# File 'lib/off_github.rb', line 27 def rsort(list) sort(list).reverse! end |
#sort(list) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/off_github.rb', line 10 def sort(list) ss = StringScanner.new '' pad_to = 0 list.each { |li| pad_to = li.size if li.size > pad_to } list.sort_by do |li| ss.string = li parts = '' if match = ss.scan_until(/\d+|[a-z]+/i) parts << match.rjust(pad_to) end until ss.eos? parts end end |