1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
items.map{|item| [f.call(item).scan(/\d+|[^\d]/).map{|e| # split string on numeral and other symbols if e.to_i.to_s == e # is_int? 256+e.to_i # up char code else e[0] # char code end }, item] }.sort{|a,b| n = [a[0].count,b[0].count].min-1 # minimum length of two strings r = a[0][0..n] <=> b[0][0..n] r == 0 ? a[0].count <=> b[0].count : r }.map{|_,e| e} end |

