I'm looking at the following code from SolrIndexSearcher.getDocListNC:
final FieldSortedHitQueue hq = new FieldSortedHitQueue(reader, lsort.getSort(), offset+len); searcher.search(query, new HitCollector() { public void collect(int doc, float score) { if (filt!=null && !filt.exists(doc)) return; numHits[0]++; hq.insert(new FieldDoc(doc, score)); } } ); totalHits = numHits[0]; maxScore = totalHits>0 ? hq.getMaxScore() : 0.0f; nDocsReturned = hq.size(); ids = new int[nDocsReturned]; scores = (flags&GET_SCORES)!=0 ? new float[nDocsReturned] : null; for (int i = nDocsReturned -1; i >= 0; i--) { FieldDoc fieldDoc = (FieldDoc)hq.pop(); // fillFields is the point where score normalization happens // hq.fillFields(fieldDoc) ids[i] = fieldDoc.doc; if (scores != null) scores[i] = fieldDoc.score; } Why are the document IDs and scores being retrieved from the PriorityQueue in reverse order? I'm missing something obvious. Thanks, Peter