Sequence result = new ValueSequence();
Sequence selected = select.eval(contextSequence, contextItem);
Collator collator = getCollator(contextSequence, contextItem, 2);
TreeMap<AtomicValue, Sequence> map = new TreeMap<AtomicValue, Sequence>(new ValueComparator(collator));
Item item;
AtomicValue value;
NumericValue firstNaN = null;
for (SequenceIterator i = selected.iterate(); i.hasNext();) {