title: How to sort Employee object based on salary,name in ascending order from Map<String, Map<String, ArrayList<Employee>>>using Java8 streams API
body: <pre><code>Map&lt;String, Map&lt;String, ArrayList&lt;Employee&gt;&gt;&gt; map = new HashMap&lt;String, Map&lt;String, ArrayList&lt;Employee&gt;&gt;&gt;();
  ArrayList&lt;Employee&gt; list = new ArrayList&lt;Employee&gt;();
  Map&lt;String, ArrayList&lt;Employee&gt;&gt; empMap = new HashMap&lt;&gt;();
  
  Employee e1 = new Employee(&quot;Raju&quot;, 10000);
  Employee e2 = new Employee(&quot;Naresh&quot;, 2000);
  Employee e3 = new Employee(&quot;Sugg&quot;, 30000);
  Employee e4 = new Employee(&quot;Asd&quot;, 30000);
  list.add(e1);
  list.add(e2);
  list.add(e3);
  list.add(e4);
  empMap.put(&quot;w1&quot;, list);
  
  map.put(&quot;t1&quot;, empMap);
  
  Comparator&lt;Employee&gt; cmp = (i1, i2) -&gt; i1.getSal().compareTo(i2.getSal());
  Comparator&lt;Employee&gt; cmp1 = (i1, i2) -&gt; i1.getName().compareTo(i2.getName());
  
  map.values().stream().map(m -&gt; {
      return m.values().stream().map(l -&gt; {
          l.sort(cmp.thenComparing(cmp1));
          return l;
      });
  }).flatMap(m -&gt; m).forEach(l -&gt; {
      l.forEach(l1 -&gt; System.out.println(l1.getName() + &quot; &quot; + l1.getSal()));
  });
  </code></pre>
  <p>Map is the main object, empMap is the map inside main map, list is the list of Employee objets.
  I tried the sorting in above but Is any other way above code can be optimized?</p>