I have the following structures: list of lists of MyObject, and comparator that compares 2 MyObjects
The task is to get up to N lesser objects from the list.
The problem may be solved by several ways:
To put all elements in one new list and to sort it using Collections.sort() or Arrays.parallelSort()
To put all elements into ProirityQueue and then retrive N top elements
To put all elements in SortedSet (TreeSet) and retrieve needed elements using iterator
I don't know wich way to choice. The creteria is performance. The size of "internal list" is about 20 elements and "outer" list size is about 10