Skip to content

Use case-insensitive locale-aware sorting for Acknowledgements#41

Merged
MartinP7r merged 1 commit into
mainfrom
fix/case-insensitive-sorting
Mar 8, 2026
Merged

Use case-insensitive locale-aware sorting for Acknowledgements#41
MartinP7r merged 1 commit into
mainfrom
fix/case-insensitive-sorting

Conversation

@MartinP7r

Copy link
Copy Markdown
Owner

Summary

  • Unify sorting behavior: Comparable now uses localizedStandardCompare instead of plain <
  • all() delegates to .sorted() instead of using a separate .lowercased() closure
  • All 16 tests pass

Supersedes #38 (which targeted the already-merged feature/bug-fixes-and-tests branch).

Test plan

  • All existing tests pass (16/16)
  • testSortingIsCaseInsensitive validates ["apple", "Banana", "Zebra"] ordering

Replace inconsistent sorting: Comparable used case-sensitive comparison
while all() used .lowercased(). Now both use localizedStandardCompare
via the Comparable conformance, which handles locale-specific ordering.

Closes #38
@MartinP7r MartinP7r self-assigned this Mar 8, 2026
@MartinP7r MartinP7r marked this pull request as ready for review March 8, 2026 07:22
Copilot AI review requested due to automatic review settings March 8, 2026 07:22
@MartinP7r MartinP7r merged commit d54dad7 into main Mar 8, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR unifies the Acknowledgement sorting behavior to be case-insensitive and locale-aware by switching the Comparable implementation from plain string < to localizedStandardCompare(_:), and simplifying all() to delegate to .sorted(). It also updates tests to validate the new case-insensitive ordering.

Changes:

  • Acknowledgement.Comparable now uses localizedStandardCompare(_:) instead of raw <
  • Acknowledgement.all() simplified to acks.sorted(), delegating to Comparable
  • Tests renamed and updated to reflect case-insensitive expectations

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Sources/AckGenCore/Acknowledgement.swift Switches < to localizedStandardCompare; simplifies all() to .sorted()
Tests/AckGenTests/AcknowledgementTests.swift Renames test and updates expected sort order to case-insensitive
Tests/AckGenTests/AckGenTests.swift Updates testAllReturnsSorted to use .sorted() instead of the old lowercased closure

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +67 to 68
let sorted = items.sorted()
XCTAssertEqual(sorted.map(\.title), ["apple", "Mango", "Zebra"])

Copilot AI Mar 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In testAllReturnsSorted, the test creates a plist file on disk and initializes bundle, but neither is actually used — Acknowledgement.all(fromPlist:in:) is never called in this test. The plist is written to a temp directory and then deleted, but the sorting is verified by calling items.sorted() directly on the local array, bypassing the all() method entirely.

This means the test does not actually validate that Acknowledgement.all(fromPlist:in:) returns a correctly sorted result. The bundle setup and file I/O are dead code. The test should either be updated to call Acknowledgement.all(fromPlist:in:) with a properly resolved bundle (or a custom URL-based loader), or the dead code should be removed and a comment added explaining why all() is not directly tested here.

Copilot uses AI. Check for mistakes.
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.

2 participants