Skip to content

Instantly share code, notes, and snippets.

@Hamcha
Created September 22, 2012 16:26
Show Gist options
  • Save Hamcha/3766666 to your computer and use it in GitHub Desktop.
Save Hamcha/3766666 to your computer and use it in GitHub Desktop.
Paradise reordering
$paradise = { YOUR MEGA WORLD THING HERE }
$paradise.each do |p|
parent = p[1]["parent"]
if $paradise.has_key?(parent)
unless $paradise[parent].has_key?("childs")
$paradise[parent]["childs"] = Array.new
end
$paradise[parent]["childs"].push(p)
$paradise.delete(p)
end
end
print $paradise.inspect
@neauoire
Copy link

html = ""
vessel = Hash.new

if @vessel['parent'].to_i == 4

  qr_horaire = $quest.query("SELECT Parent,id,Security FROM PHL_Paradise ORDER BY id ASC")  
  while row = qr_horaire.fetch_row do
    vessel[row[1].to_i] = row[0].to_i
  end


  vessel.each do |p|
        parent = p[1]["parent"].to_i
        if vessel.has_key?(parent) 
            unless vessel[parent].has_key?("childs") 
                vessel[parent]["childs"] = Array.new
            end
            vessel[parent]["childs"].push(p)
            vessel.delete(p)
        end
    end

  puts "<pre>"
  pp vessel.sort
  puts "</pre>"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment