title: Sorting Arrays.asList In Java
body: <pre><code>import java.util.Arrays;
  import java.util.List;
  
  public class CapitalizeAndSort {
      public static void main(String[] args) {
  
          List&lt;String&gt; topNames2017 = Arrays.asList(
              "Amelia", 
              "Olivia", 
              "emily", 
              "Isla", 
              "Ava", 
              "oliver", 
              "Jack",
              "Charlie", 
              "harry", 
              "Jacob"
          );               
  
          for(int i = 0; i &lt; topNames2017.size(); i++) {
              topNames2017.set(i, capitalize(topNames2017.get(i))); 
          }   
  
          List&lt;String&gt; sorted = Arrays.asList(
              topNames2017.stream().sorted(
                  (s1, s2) -&gt; s1.compareToIgnoreCase(s2)
                  ).toArray(String[]::new)
              );
  
          sorted.forEach(System.out::println);
      }
      private static String capitalize(final String line) {
          return Character.toUpperCase(line.charAt(0)) + line.substring(1);
      }
  }
  </code></pre>
  
  <p>The above code works and sorts it the way I want to.</p>
  
  <p>How can I sort that alphabetically and making sure the first letter is capitalized using method references? </p>
  
  <p>Help is greatly appreciated! </p>