private static Object transform(Object o) {
        // we want to sort the underlying object contained by the traverser
        if (o instanceof Traverser)
            o = ((Traverser) o).get();
        // need to convert enum to string representations for comparison or else you can get cast exceptions.
        // this typically happens when sorting local on the keys of maps that contain T
        if (o instanceof Enum)
            o = ((Enum) o).name();
        return o;
    }
Strip the Traverser layer and convert Enum to string.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/Order.java