Skip to content

Instantly share code, notes, and snippets.

@universal
Forked from scott2619/gist:9c5efbdb455a8b9ea523
Last active August 29, 2015 14:19
Show Gist options
  • Save universal/47e0ee7681dfb096edb2 to your computer and use it in GitHub Desktop.
Save universal/47e0ee7681dfb096edb2 to your computer and use it in GitHub Desktop.
list = [128, 110, 60, 126]
list2 = [60, 110, 126]
res = list.each_with_index.each_with_object({}) {|(k,id), res| res[k] = id}
list 3 = list2.sort_by {|a| res[a]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment