Community
Participate
Working Groups
At the moment, the DeferredContentProvider does not use a stable sort algorithm for sorting elements. As an effect, each invocation of "DeferredContentProvider.setSortOrder(Comparator)" completely resorts the entire element list without preserving previous sort orders (for elements that are concerned to be equal according to the newly set sort order comparator). So e.g. it is not possible to first sort a contact list by name and then sort it by zip code preserving the (previous) sort order for all contacts with equal zip codes.
Currently, we don't have the resources to address this. Patches (including JUnit test cases) would be welcome!
Hitesh is now responsible for watching bugs in the [Viewers] component area.
Bug still exists in Eclipse Neon.3 (4.6.3).
(In reply to Mario Winterer from comment #3) > Bug still exists in Eclipse Neon.3 (4.6.3). And we still accept patches...
I started to look at this defect, but im not so sure this is something that should be implemented. Since the responsibility of sorting lies on the Comparator i think the reasonable thing would be if the Comparator remembers previous sort orders instead of making the content provider care about sorting. In java 8 you could use the thenCompare method to add previous Comparators.
No, that's not true. Stability is usually a property of the sort algorithm itself and has nothing to do with the comparison operator. E.g. Merge Sort is stable, while Quick Sort isn't. The question is if equal elements might switch their (relative) positions during sorting or not. I'm not sure if common partial sorting algorithms are usually stable or not. Possibly solving this issue might require a total new implementation of the sorting strategy. By the way - this issue is so old, I don't really care any more.
But there is a easy workaround for this issue: We use a meta-comparator that delegates to a list of comparators for comparison. This list holds the current sort order comparator in its first place as well as all previously used comparators. Whenever a "current" comparator is set on the meta-comparator, it is inserted at the first position or, if already in the list, moved to the first position in the list.