// get an iterator over the groups in "order of first appearance"
GroupIterator groupIterator;
switch (algorithm) {
case GROUP_BY: {
StringCollator coll = collator;
if (coll==null) {
// The collation is determined at run-time
coll = getCollator(context);
}
XPathContext c2 = context.newMinorContext();
c2.setCurrentIterator(population);
groupIterator = new GroupByIterator(population, key, c2, coll);
break;
}
case GROUP_ADJACENT: {
StringCollator coll = collator;
if (coll==null) {
// The collation is determined at run-time
coll = getCollator(context);
}
groupIterator = new GroupAdjacentIterator(population, key, context, coll);