Incorrect sorting of symbols and strings?
ideasasylum opened this issue · 2 comments
As mentioned here there's a problem inside Tilt::Template where it will try to sort an array of mixed Strings and Symbols in Ruby >1.9. Unless I'm missing something, sorting mixed arrays doesn't work in any version of Ruby.
See this commit where the problem was introduced: 4e1b2ea cc. @jeremyevans
See an IRB session in Ruby 2.2:
$ irb
irb(main):001:0> array = [:c, 'a', :b, "e", 'f', :d]
=> [:c, "a", :b, "e", "f", :d]
irb(main):002:0> array.sort!
ArgumentError: comparison of Symbol with String failed
from (irb):2:in `sort!'
from (irb):2
from /Users/jamie/.rbenv/versions/2.2.3/bin/irb:11:in `<main>'
$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
Am I missing something? I could create a PR to fix this if it's agreed
We should probably switch to always sorting by strings, it's probably just a small performance hit. We do need to keep sorting unless there are no locals, as otherwise we run into the 2**N cache entry issue. @ideasasylum if you want to create a PR for that, please do so, otherwise, I can probably work on it soon.
ah, you're too quick for me @jeremyevans. Thanks for fixing it! 👍