Created
April 19, 2013 18:42
-
-
Save TXDynamics/5422324 to your computer and use it in GitHub Desktop.
Ruby Sorting Arrays temporarily and then permanently
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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