result.sort();
	public NodeSet findElementsByTagName(byte type, DocumentSet docs, QName qname,		NodeSelector selector) {		final long start = System.currentTimeMillis();		final ExtArrayNodeSet result = new ExtArrayNodeSet(docs.getLength(), 256);		DocumentImpl doc;		int docId;		int len;		short collectionId;		long gid;		VariableByteInput is = null;		ElementValue ref;		short sym, nsSym;		Collection collection;		NodeProxy p;		final short nodeType =			(type == ElementValue.ATTRIBUTE ? Node.ATTRIBUTE_NODE : Node.ELEMENT_NODE);		final Lock lock = elementsDb.getLock();		for (Iterator i = docs.getCollectionIterator(); i.hasNext();) {			collection = (Collection) i.next();			collectionId = collection.getId();			if (type == ElementValue.ATTRIBUTE_ID) {				ref = new ElementValue((byte) type, collectionId, qname.getLocalName());			} else {				sym = getSymbols().getSymbol(qname.getLocalName());				nsSym = getSymbols().getNSSymbol(qname.getNamespaceURI());				ref = new ElementValue((byte) type, collectionId, sym, nsSym);			}			boolean exceptionOcurred = false;			try {				lock.acquire(Lock.READ_LOCK);				is = elementsDb.getAsStream(ref);			} catch (LockException e) {                LOG.warn(                    "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - "                        + "failed to acquire lock",                    e);				// jmv: dis = null;				exceptionOcurred = true;			} catch (IOException e) {                LOG.warn(                    "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - "                        + "io exception while reading elements for "                        + qname,                    e);				// jmv: dis = null;				exceptionOcurred = true;			} finally {				lock.release();			}			// jmv: if (dis == null)			// wolf: dis == null if no matching element has been found in the index			if (is == null || exceptionOcurred)				continue;			try {				while (is.available() > 0) {					docId = is.readInt();					len = is.readInt();					if ((doc = docs.getDoc(docId)) == null) {						is.skip(len * 4);						continue;					}					gid = 0;					for (int k = 0; k < len; k++) {						gid = gid + is.readLong();						p = new NodeProxy(doc, gid, nodeType, StorageAddress.read(is));						if(selector == null || selector.match(p))							result.add(p, len);					}				}			} catch (EOFException e) {			} catch (IOException e) {                LOG.warn(                    "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - "                        + "unexpected io error",                    e);			}		}//		result.sort();//				LOG.debug(//					"found "//						+ qname//						+ ": "//						+ result.getLength()//						+ " in "//						+ (System.currentTimeMillis() - start)//						+ "ms.");		return result;	}