title: How can I sort a list of maps by value of some specific key using Java 8?
body: <p>How can I sort a <code>List</code> of <code>Map&lt;String, String&gt;</code> using Java 8? The map contains a key called <code>last_name</code>, and the value associated with it may be <code>null</code>. I'm not sure how to do it because the following results in a compiler error:</p>
  
  <pre><code>List&lt;Map&lt;String, String&gt;&gt; peopleList = ...
  
  peopleList.sort(Comparator.comparing(Map::get, Comparator.nullsLast(Comparator.naturalOrder())));
  </code></pre>
  
  <p>Is using an anonymous class the only way to do it?</p>
  
  <p>Note that I am <strong>not</strong> trying to sort each map in the list. I want to sort the list itself based on a key in each map.</p>