- if (resultCount < result2.size())
- result2 = result2.subList(0, resultCount);
+ if (resultCount < result2.size()) {
+ double limitValue = (double) result2.get(resultCount-1).c1;
+
+ // Expand selection to contain all items with the same value as the nth one
+ int count = resultCount;
+ while (count < result2.size() && (double)result2.get(count).c1 == limitValue) count++;
+ result2 = result2.subList(0, count);
+ }