@Test
    public void sortingOrderIndependentOfValueInsertionOrder() {
        StructDataType type = new StructDataType("test");
        type.addField(new Field("int", DataType.INT));
        type.addField(new Field("flt", DataType.FLOAT));
        type.addField(new Field("str", DataType.STRING));

        Struct a = new Struct(type);
        a.setFieldValue("int", new IntegerFieldValue(123));
        a.setFieldValue("flt", new DoubleFieldValue(45.6));
        a.setFieldValue("str", new StringFieldValue("hello world"));
        Struct b = new Struct(type);
        b.setFieldValue("str", new StringFieldValue("hello world"));
        b.setFieldValue("flt", new DoubleFieldValue(45.6));
        b.setFieldValue("int", new IntegerFieldValue(123));

        assertEquals(0, a.compareTo(b));
        assertEquals(0, b.compareTo(a));
        assertTrue(a.equals(b));
        assertTrue(b.equals(a));

        b.setFieldValue("int", new IntegerFieldValue(122));
        assertTrue(a.compareTo(b) > 0);
        assertTrue(b.compareTo(a) < 0);
        assertFalse(a.equals(b));
        assertFalse(b.equals(a));
    }
@author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java