Join Kevin Skoglund for an in-depth discussion in this video Sorting, part of Ruby Essential Training.
In the last movie we were able to add arguments that could be passed through…to the find method.…I think another great feature would be able to take those same arguments and…pass them to the list method and let it use them to sort the list.…So we could actually have a way of sorting the list by name, by cuisine, or by price.…You probably have enough skills to do this on your own at this point, but I am…going to go ahead and walk you through it.…So we already have the do_action receiving the arguments that came in from the user.…So all we need to do now is pass those arguments into list, and I am going to…pass all the args in.…Instead of trying to tease out what I need ahead of time, I am just going to…pass them all in to the list.…
So the list now is going to have args =, and just in case we'll have an empty array.…So we are going to go ahead and do the output and everything, but first we want…to figure what the sort_order ought to be.…So sort_order, let's look at those arguments, and the sort_order ought to be…
- Using Ruby in the Interactive Ruby Shell and in standalone scripts
- Learning to write custom code blocks to find, merge, and sort
- Using modules for namespacing or as mix-ins
- Reading from and writing to files
- Creating a full Ruby project from start to finish
Skill Level Beginner
1. Getting Started with Ruby
2. Ruby Object Types
3. Control Structures
4. Code Blocks
8. Working with Files
9. Ruby Project: Creating the Food Finder
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.