From the course: Data Science for Java Developers
Unlock this course with a free trial
Join today to access over 22,500 courses taught by industry experts.
Sorting - Java Tutorial
From the course: Data Science for Java Developers
Sorting
- [Speaker] So we've covered mapping, filtering, and collecting, and the last method that we're going to cover here that's relevant at this point in the game is the sorted method. So, the sorted method is used a lot like filter or map, or collect, it's called on a stream. And what it'll do is, it'll allow us to sort the data in that stream into a different order than we originally had it. So for instance here, our numbers here are already in order. At least, ascending order. But we might want to do something like sort our words in our words list alphabetically, or do something like sort our employees alphabetically by name, or sort them by their salary, something like that. Now, the way that we do that again, is using the sorted method. And I'm just going to show you what that looks like. So, as our example here, let's say we wanted to sort our employees in ascending order by their salary, what that would look like,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.