title: Sorting this Map<String, FullName> in Java
body: <p>I have a Map where FullName is an object and contains another object of class Name that contains FirstName and LastName. Firstname and last names are String. (Yes i know its a bad design, but i am trying to learn sorting)</p>
  
  <p>The key String is just id's such as 1,2,3,...</p>
  
  <p>I want to sort based on the full name(both firstname and last name), and just return a list of id's.</p>
  
  <p>This is the code i have so far, but i am getting a syntax error on the sorted portion where i am passing the comparator. And also I am pretty sure i am doing something incorrect semantically too.</p>
  
  <pre><code>List&lt;String&gt; listofIds = map.entrySet().stream()
              .sorted(new ValueComparator(map))
              .map(Map.Entry::getKey)
              .collect(toList());
  
  class ValueComparator implements Comparator&lt;String&gt; {
      Map&lt;String, FullName&gt; base;
  
      public ValueComparator(Map&lt;String, FullName&gt; base) {
          this.base = base;
      }
  
      public int compare(String a, String b) {
          FullName fullName1 = base.get(a);
          FullName fullName2 = base.get(b);
          return(fullName1.getName().getFirstName()
                 .compareTo(fullName2.getName().getFirstName()));
      }
  }
  </code></pre>