Created
September 28, 2017 15:45
-
-
Save johnivanoff/223fd9042f3d8a6b0b91cafd7d776c92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
placeholderA = [] | |
placeholderB = [] | |
fh.each do |key, value| | |
case key | |
when "sortdescending" | |
placeholderA << "a['#{value}']" | |
placeholderB << "b['#{value}']" | |
when "sortascending" | |
placeholderA << "b['#{value}']" | |
placeholderB << "a['#{value}']" | |
else | |
next | |
end | |
arr.sort { |a, b| [placeholderA] <=> [placeholderB] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem is I get.
arr.sort { |a, b| ["a['price'], a['name']"] <=> ["b['price'], b['name']"] }
and not
arr.sort { |a, b| [a['price'], a['name']] <=> [b['price'], b['name']] }
How do I make not string?