Comparator<Map.Entry<String, Node>> metadataComparator() {
        switch (this) {
            case ALPHA_NUMERIC:
            case PREFERRED:
                return Map.Entry.comparingByKey();
            case SOURCE_LOCATION:
            default:
                return new MetadataComparator();
        }
    }
Reorganizes shapes based on a preferred ordering of shapes, and alphanumeric traits and metadata.

<p>Shapes are ordered as follows:

<ul>
    <li>Trait definitions</li>
    <li>Services</li>
    <li>Resources</li>
    <li>Operations</li>
    <li>Structures</li>
    <li>Unions</li>
    <li>Lists</li>
    <li>Maps</li>
    <li>Finally, alphabetically by shape type.</li>
</ul>
smithy-model/src/main/java/software/amazon/smithy/model/shapes/SmithyIdlComponentOrder.java