Redundant? Not really: to get the cell value from an item, one needs a pointer to the column. Since the existing machinery already computes the value, we just pass it along with (what is missing now) a pointer to the item. I think it's more "convenient", and one could possibly reuse the sort policy for multiple columns.
I don't know whether the column pointer needs to be passed - probably not, but perhaps I don't see scenarios where it might be needed, and it makes the policy more complicated since we now have to have separate policies for TableView and TreeTableView. Example: public interface SortPolicy<ITEM,VALUE> { public int compare(Tree/TableColumn column, ITEM itemA, VALUE valueA, ITEM itemB, VALUE valueB); } What do everyone think? -andy From: openjfx-dev <openjfx-dev-r...@openjdk.org> on behalf of PavelTurk <pavelturk2...@gmail.com> Date: Monday, May 19, 2025 at 17:21 To: openjfx-dev@openjdk.org <openjfx-dev@openjdk.org> Subject: Re: Let's discuss JDK-8338952 Andy, I think this is a good solution because it provides everything needed for sorting. Moreover, it complies with the generics of TableColumn. For example, var column = new TableColumn<Person, String>("First Name"); SortPolicy<Person, String> sortPolicy = ... column.setSortPolicy(sortPolicy); But don't you think the VALUE parameters are redundant since they can be obtained directly from ITEM? Best regards, Pavel On 5/19/25 22:28, Andy Goryachev wrote: One possible solution would be to deprecate the comparator property (not for removal, keep it for backward compatibility), and add a new property 'sortPolicy' which will use an interface that can be evolved, as opposed to a naive callback. public interface SortPolicy<ITEM,VALUE> { public int compare(ITEM itemA, VALUE valueA, ITEM itemB, VALUE valueB); } when set, the new property will override the comparator property. What do you think? -andy From: openjfx-dev <openjfx-dev-r...@openjdk.org><mailto:openjfx-dev-r...@openjdk.org> on behalf of PavelTurk <pavelturk2...@gmail.com><mailto:pavelturk2...@gmail.com> Date: Monday, May 19, 2025 at 00:59 To: openjfx-dev@openjdk.org<mailto:openjfx-dev@openjdk.org> <openjfx-dev@openjdk.org><mailto:openjfx-dev@openjdk.org> Subject: Let's discuss JDK-8338952 About six months ago, I opened JDK-8338952 with a proposal to add an item comparator to (Tree)TableView. The reason for this issue is that when using non-standard sorting — for example, when there is a "Total" row in the table — the standard API becomes insufficient. One has to reinvent the wheel, and the code quickly becomes extremely messy. Given that tables are one of the core UI components, this becomes a serious problem. To address this, I proposed adding an item comparator, which I believe would be very simple to implement. I suggest we at least discuss this issue so we can start moving toward a solution. Best regards, Pavel