Skip to content

Instantly share code, notes, and snippets.

@Jayasagar
Created December 17, 2017 15:12
Show Gist options
  • Save Jayasagar/a71cd03595629b84c15e7107932fd98c to your computer and use it in GitHub Desktop.
Save Jayasagar/a71cd03595629b84c15e7107932fd98c to your computer and use it in GitHub Desktop.
// User Bob devices sort by name
List<Thing> bobDevicesSortByName = bob.getThings()
.stream()
// sorted is an intermediate operation
.sorted(Comparator.comparing(Thing::getName))
.collect(Collectors.toList());
System.out.println(bobDevicesSortByName);
// Output: [Thing(name=AgriFieldSensor), Thing(name=Bulb), Thing(name=EyeVirusDetector), Thing(name=MotionDetector)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment