stevedlawrence commented on a change in pull request #262: Unordered sequences
URL: https://github.com/apache/incubator-daffodil/pull/262#discussion_r318167046
##########
File path:
daffodil-runtime1/src/main/scala/org/apache/daffodil/infoset/InfosetImpl.scala
##########
@@ -1415,6 +1415,10 @@ sealed class DIComplex(override val erd:
ElementRuntimeData, val tunable: Daffod
}
}
+ final def sortChildNodesByPosition(): Unit = {
+ childNodes = childNodes.sortBy(_.erd.position)
+ }
Review comment:
Does this work correctly if there is an unordred sequence inside a sequence?
e,g.
``` xml
<xs:sequence>
<xs:element name="foo" ... />
<xs:element name="bar" ... />
<xs:sequence dfdl:sequenceKind="unordred">
<xs:element name="baz" ... />
<xs:element name="qaz" ... />
</xs:sequence>
</xs:sequence>
```
In this case, we're going to include foo and bar in the sort. We really only
want to sort the elements that are in the unordred sequence.
It would also be nice if we could sort in-place so that we don't have to
create a duplicate array of children. I'm not sure if Scala's ArrayBuffer
provides a method to sort an array in-place on a subset of the array, but
Java's ``Arrays`` object has the ``sort(T[] a, int fromIndex, int toIndex,
Comparator<? super T> c)`` method. Is it worth switching from ArrayBuffer to a
java Array (and handle resizing ourselves) to get an efficieint in place sort
of unordered elements?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services