try query9 with heap, instead of collecting all and sorting at the end