package java8.stream;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @Author: yoyo
 * @Description:
 * @Date: Created in 2019/8/28 16:12
 */
public class ListBeanSort {

    public static void main(String[] args) {
        List<Student> students = List.of(new Student(12,"Ricky"),new Student(24,"Dan"),new Student(30,"Cusy"));

        students.parallelStream().sorted(Comparator.comparing(Student::getAge));

        System.out.println(students);
    }


   static class Student {
        private int age;
        private String name;

       @Override
       public String toString() {
           return "Student{" +
                   "age=" + age +
                   ", name='" + name + '\'' +
                   '}';
       }

       public Student(int age, String name) {
            this.age = age;
            this.name = name;
        }

        public int getAge() {
            return age;
        }

        public void setAge(int age) {
            this.age = age;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}

@@ -20,36 +20,8 @@
 m;%0A%0A
-import java.util.ArrayList;%0A
 impo
@@ -67,16 +67,52 @@
 il.List;
+%0Aimport java.util.stream.Collectors;
 %0A%0A/**%0A *
@@ -315,11 +315,12 @@
 ent(
-1
+4
 2,
+ 
 %22Ric
@@ -324,16 +324,17 @@
 Ricky%22),
+ 
 new Stud
@@ -344,15 +344,17 @@
 (24,
+ 
 %22Dan%22),
+ 
 new 
@@ -364,16 +364,17 @@
 dent(30,
+ 
 %22Cusy%22))
@@ -383,16 +383,42 @@
 %0A       
+ //%E5%8D%87%E5%BA%8F%E6%8E%92%E5%88%97%0A        students =
  student
@@ -481,16 +481,45 @@
 getAge))
+.collect(Collectors.toList())
 ;%0A%0A     
@@ -544,108 +544,585 @@
 tln(
-students);%0A    %7D%0A%0A%0A   static class Student %7B%0A        private int age;%0A        private String name;%0A%0A
+%22%E5%8D%87%E6%8E%92%E5%88%97%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%22);%0A        students.parallelStream().forEach(o -%3E %7B%0A            System.out.println(o);%0A        %7D);%0A%0A        //%E9%99%8D%E5%BA%8F%E6%8E%92%E5%88%97%0A        students = students.parallelStream().sorted(Comparator.comparing(Student::getAge).reversed()).collect(Collectors.toList());%0A        System.out.println(%22%E9%99%8D%E5%BA%8F%E6%8E%92%E5%88%97%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%E3%80%82%22);%0A        students.parallelStream().forEach(System.out::println);%0A    %7D%0A%0A%0A    static class Student %7B%0A        private int age;%0A        private String name;%0A%0A        public Student(int age, String name) %7B%0A            this.age = age;%0A            this.name = name;%0A        %7D%0A%0A 
     
@@ -1134,16 +1134,17 @@
 verride%0A
+ 
        p
@@ -1165,24 +1165,25 @@
 oString() %7B%0A
+ 
            r
@@ -1220,16 +1220,17 @@
         
+ 
 %22age=%22 +
@@ -1236,16 +1236,17 @@
 + age +%0A
+ 
         
@@ -1306,127 +1306,14 @@
     
+ 
 '%7D';%0A
-       %7D%0A%0A       public Student(int age, String name) %7B%0A            this.age = age;%0A            this.name = name;%0A
     

add stream sorted print result