title: Sorting: How to create a particular custom order, then alphabetic sort in java
body: <p>I have an Enum with around 70 fields.</p>
  
  <p>I want 10 of them to be displayed in a particular order, then I want the rest to be displayed alphabetically using a Comparator. I have tried many things, but I can't get it to work.</p>
  
  <p>Here is a sample enum with reduces attributes
  <strong>I want Picard, Worf and William to display first, then the rest alphabetically</strong></p>
  
  <p>I cannot use any third libraries. It must be java core. So if you want to provide guava answers, or apache commons answer, please do so in addition to java core.</p>
  
  <pre><code>public enum StarTrek {
  
      JeanLucPicard("Picard"),
      GeordiLaForge("Geordi"),
      DiannaTroi("Dianna"),
      Worf("Worf"),
      WilliamRiker("William"),
      Q("Q");
  
      private String label;
  
      StarTrek(String label) { this.label = label; }
  
      @Override public String toString() { return label; }
  }
  
      List&lt;StarTrek&gt; specificOrder = Arrays.asList(StarTrek.JeanLucPicard, StarTrek.Worf, StarTrek.WilliamRiker);
  
      Comparator&lt;StarTrek&gt; comp = new Comparator&lt;StarTrek&gt;() {
              @Override
              public int compare(StarTrek o1, StarTrek o2) {
                  //TODO: loop through the specific order, and display those first, then for the rest, go alphabetic
                  return 0;
              }
      };
  
      List&lt;StarTrek&gt; all = Arrays.asList(StarTrek.values());
      Collections.sort(all, comp);
  </code></pre>