Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Many of the table column comparators (as well as PaymentMethod.compareTo) are invalid, since they immediately return 0 upon encountering a null/missing field. This violates the Comparator/Comparable contract, which expects a total order on the objects and, in particular, an equivalence relation given by the result of "compare(x, y) == 0".
This PR attemps to fix all the invalid Comparator / Comparable instances (which are almost all table column comparators), by ordering objects with a null/missing (sub)field ahead of the populated ones. In most cases this will probably have no effect, as nulls won't be encountered for that column in practice. However, the current flawed comparators are at least breaking row sorting in the Portfolio/History table, as seen in the following two screenshots:
The ascending/descending sorting of the "Amount in BTC" field does not make sense, due to a broken comparator passed to the underlying FX library insertion sort. After the fix, the rows appear as follows:
The missing cells are deemed smaller than all the others in the column, which is consistent with TableColumnBase.DEFAULT_COMPARATOR from the openjfx library.