Fixed sorting logic - #1820
Open
HrshD1eux wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR resolves core flaws in how Vault Entries are sorted by Account and Issuer, addressing both locale-awareness and incorrect reversed chaining.
1. Fixed Reversed Secondary Sort Key Bug
Account (Z to A)orIssuer (Z to A), the application was applyingCollections.reverseOrder()to the entire chained comparator. This incorrectly forced the secondary sort key to also reverse (e.g., identical accounts would have their issuers sorted Z to A).SortCategory.javato applyCollections.reverseOrder()strictly to the primary comparator before chaining the secondary one via.thenComparing(). Secondary sort keys now correctly remain A to Z.2. Implemented Locale-Aware Alphabetical Sorting
AccountNameComparatorandIssuerNameComparatorrelied onString.compareToIgnoreCase(), which performs raw Unicode code point comparisons. This caused accented and localized characters (e.g., 'Ä') to be banished to the end of lists. It also resulted in unstable, non-deterministic sorting for identical strings that only differed by casing.Collator.getInstance()set toSECONDARYstrength. This ensures natural alphabetical sorting that respects the user's local language rules. A strict case-sensitive fallback was also added to guarantee stable, deterministic ordering for ties.Testing
Z to Asorts now properly maintainA to Zordering for tie-breakers../gradlew assembleDebugwith zero errors.