Skip to content

Instantly share code, notes, and snippets.

@ilake
Created December 6, 2013 05:35
Show Gist options
  • Save ilake/7819063 to your computer and use it in GitHub Desktop.
Save ilake/7819063 to your computer and use it in GitHub Desktop.
# The user order I want
ids = [1, 3, 5, 9, 6, 2]
indexed_people = Person.find(ids).index_by(&:id)
people_in_order = indexed_people.values_at(*ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment