title: how to sort nested lists in java
body: <p>I have a json like below :</p>
  
  <pre><code>{ 
    "Student": [
      {  
        "name":"5",
        "Roll No":12345,
        "Subjects":[  
          {  
             "subjectCode":"Mat"
          },
          {  
             "subjectCode":"Sci"
          }
        ]
      } 
    ]
  }
  </code></pre>
  
  <p>I want to sort list of subjects within each student and then sorting student objects with roll no.Can it be done with java8 in single line.</p>
  
  <p>I am using below code : </p>
  
  <pre><code>list.forEach(studentObj -&gt; {
      studentObj.getSubjects()
        .sort(Comparator.nullsLast(Comparator.comparing(Subject:: getSubjectCode)));
    });
  </code></pre>
  
  <p>then sorting the outside object</p>
  
  <pre><code>  list.sort(Comparator.nullsLast(Comparator.comparing(Student:: getRollNo)));
  </code></pre>