Skip to content

Fixed sorting logic - #1820

Open
HrshD1eux wants to merge 2 commits into
beemdevelopment:masterfrom
HrshD1eux:fix-sorting-logic
Open

Fixed sorting logic#1820
HrshD1eux wants to merge 2 commits into
beemdevelopment:masterfrom
HrshD1eux:fix-sorting-logic

Conversation

@HrshD1eux

Copy link
Copy Markdown

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

  • Issue: When sorting by Account (Z to A) or Issuer (Z to A), the application was applying Collections.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).
  • Fix: Updated SortCategory.java to apply Collections.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

  • Issue: AccountNameComparator and IssuerNameComparator relied on String.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.
  • Fix: Replaced standard string comparison with Collator.getInstance() set to SECONDARY strength. 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

  • Validated via raw Java simulations against dummy vault entries.
  • Accented characters now sort adjacent to their base letters.
  • Z to A sorts now properly maintain A to Z ordering for tie-breakers.
  • Project compiles via ./gradlew assembleDebug with zero errors.

@HrshD1eux HrshD1eux changed the title Fix sorting logic Fixed sorting logic Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant