Created
August 21, 2015 03:05
-
-
Save milushov/82832492356f6730bfa2 to your computer and use it in GitHub Desktop.
This file contains 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
def self.stupid_arrange | |
arranged = ActiveSupport::OrderedHash.new | |
self.sorted.where(depth: 0).each do |item| | |
arranged[item] = [] | |
end | |
self.sorted.where(depth: 1).each do |item| | |
if key = arranged.find{ |k, _| k.id == 54 }.first | |
arranged[key].push(item) | |
end | |
end | |
arranged | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment