Skip to content

Instantly share code, notes, and snippets.

@gswallow
Created April 30, 2018 18:44
Show Gist options
  • Save gswallow/601ba971409b08e8b46447fe3ffd3019 to your computer and use it in GitHub Desktop.
Save gswallow/601ba971409b08e8b46447fe3ffd3019 to your computer and use it in GitHub Desktop.
inject
order = []
lifecycle_envs.each do |e|
if e['prior'].nil?
order.unshift(e['name'])
elsif order.include?(e['prior']['name'])
order.insert(order.index(e['prior']['name']) + 1, e['name'])
else
order.push(e['name'])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment