Skip to content

Instantly share code, notes, and snippets.

@TXDynamics
Created April 19, 2013 18:42
Show Gist options
  • Save TXDynamics/5422324 to your computer and use it in GitHub Desktop.
Save TXDynamics/5422324 to your computer and use it in GitHub Desktop.
Ruby Sorting Arrays temporarily and then permanently
user_input = "foo,bar,you,know".split(',') # We use split to make an array from user input
user_input.count # this will display 4 because we store 4 values in our array
# Now we use the temp array sort method
user_input.sort
# To save the values back to the array you need to use !
user_input.sort!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment