Skip to content

Instantly share code, notes, and snippets.

@everm1nd
Created April 6, 2012 17:10
Show Gist options
  • Save everm1nd/2321413 to your computer and use it in GitHub Desktop.
Save everm1nd/2321413 to your computer and use it in GitHub Desktop.
Ruby: Sort one array by another using +/-
order = [1,2,3,4,5]
params = [5,2,1,7,9]
sort = order - (order - params) + (params - order) # => [1,2,5,7,9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment