How to do custom order on java ENUMS?
<p>I have <code>Enum</code> class as</p>

<pre><code>public enum ServiceTypes {
    Zero("zero", 6, true),
    AVL("Avl", 1, true),
    VPS("vps", 2, true),
    CALCULATOR("calculator", 3, true),
    SIMULATOR("Simulator", 4, true),
    CONTRACT("Contract Output", 5, true),
    ALL("all", 7, true);
    private static final OrderComparator orderComparator = new OrderComparator();
    private static final OrderComparator nameComparator = new OrderComparator();

    @Nonnull
    public static ServiceTypes[] getOrderedServiceTypes() {
       Arrays.sort(values(), orderComparator);
       return values();
    }

    @Nonnull
    public static ServiceTypes[] getNamedServiceTypes() {
        Arrays.sort(values(), nameComparator);
        return values();
    }

    private static final class OrderComparator implements Comparator&lt;ServiceTypes&gt; {
        @Override
        public int compare(final ServiceTypes o1, final ServiceTypes o2) {
            return o1.getOrder().compareTo(o2.getOrder());
        }
    }

    private static final class AlphabeticalOrder implements Comparator&lt;ServiceTypes&gt; {
        @Override
        public int compare(final ServiceTypes o1, final ServiceTypes o2) {
            return o1.toString().compareTo(o2.toString());
        }
    }
}
</code></pre>

<p>When I <code>test</code> <code>getOrderedServiceTypes()</code>, I see <code>Zero("zero", 6, true)</code> as the first element , which is incorrect.</p>

<p>Seems like <code>values()</code> is not sorted based on the comparator.</p>

<p>How can I run the custom orders on Enum?</p>
