NodeValueSortKey extends NodeValue implements Comparable<NodeValueSortKey> { @Override public int compareTo(NodeValueSortKey other) { Objects.requireNonNull(other); if ( this == other ) return Expr.CMP_EQUAL; String c1 = this.getCollation(); String c2 = other.getCollation(); if (c1 == null || c2 == null || ! c1.equals(c2)) return XSDFuncOp.compareString(this, other) ; Locale desiredLocale = Locale.forLanguageTag(c1); Collator collator = Collator.getInstance(desiredLocale); return collator.compare(this.getString(), other.getString()); } NodeValueSortKey(final String string, final String collation);  NodeValueSortKey(final String string, final String collation, Node n); @Override boolean isSortKey(); @Override NodeValueSortKey getSortKey(); @Override String getString(); @Override String asString(); String getCollation(); @Override void visit(NodeValueVisitor visitor); @Override String toString(); @Override int compareTo(NodeValueSortKey other);  }
@Test public void testCompareTo() { final String languageTag = "pt"; NodeValueSortKey nv = new NodeValueSortKey("Bonito", languageTag); assertEquals(1, nv.compareTo(new NodeValueSortKey("Bonita", languageTag))); assertEquals(-1, nv.compareTo(new NodeValueSortKey("Bonitos", languageTag))); assertEquals(1, nv.compareTo(new NodeValueSortKey("Bonita", "es"))); assertEquals(0, nv.compareTo(new NodeValueSortKey("Bonito", "es"))); }