YPE-2777 - feat(hooks): sort Bible versions alphabetically in Version picker#256
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 42f45c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75e269ce35
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
cameronapak
approved these changes
Jun 4, 2026
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.
Summary
localized_titlewith fallback totitle, case-insensitivelocaleCompare, andidas a stable tiebreaker.Test plan
pnpm --filter @youversion/platform-react-hooks vitest run src/useFilteredVersions.test.tsxMade with Cursor
Greptile Summary
This PR adds alphabetical sorting to the "All Versions" list in
useFilteredVersions, applied after language, search, and recent-version filters. Sorting useslocalized_titlewith a fallback totitle, the'en'locale for cross-environment consistency,sensitivity: 'base'for case/diacritic-insensitive collation, andidas a stable tiebreaker.useFilteredVersions.ts: Two pure helper functions (getVersionSortTitle,compareVersionsAlphabetically) plus a singleresult.sort()call inserted after all filter steps — clean and minimal.useFilteredVersions.test.tsx: Pre-computedsortedMockVersions/shuffledMockVersionsfixtures and a newalphabetical sortingdescribe block cover all key scenarios (localized title priority, fallback, post-filter order, search order)..changeset/…: Correctly tagged as apatchwith an accurate description.Confidence Score: 5/5
Safe to merge — the change is additive, operates on a local array copy inside useMemo, and is covered by a thorough test suite.
The sorting logic is straightforward and well-tested. It mutates only a local copy of the array, the 'en' locale is hardcoded for consistency, and the tiebreaker by id ensures a stable result. The one inconsistency (test helper using undefined locale vs the implementation's 'en') does not affect correctness in practice.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[versions input] --> B[Clone array] B --> C{selectedLanguage not wildcard?} C -- Yes --> D[Filter by language_tag] C -- No --> E{searchTerm has content?} D --> E E -- Yes --> F[Filter by title / abbreviation / ISO] E -- No --> G{recentVersions defined?} F --> G G -- Yes --> H[Exclude recent version IDs] G -- No --> I[sort via compareVersionsAlphabetically] H --> I I --> J{titles equal after base collation?} J -- No --> K[Order by localeCompare en base] J -- Yes --> L[Order by id ascending] K --> M[return sorted result] L --> MPrompt To Fix All With AI
Reviews (4): Last reviewed commit: "Merge branch 'main' into feat/sort-bible..." | Re-trigger Greptile