Skip to content

fix(sort): accept a boolean comparator and sort stably (#24, #25) - #26

Merged
skydread1 merged 1 commit into
maint-1.11.xfrom
fix/sort-comparator-predicate
Aug 20, 2026
Merged

fix(sort): accept a boolean comparator and sort stably (#24, #25)#26
skydread1 merged 1 commit into
maint-1.11.xfrom
fix/sort-comparator-predicate

Conversation

@skydread1

@skydread1 skydread1 commented Aug 20, 2026

Copy link
Copy Markdown
Member

Closes #24, Closes #25

  • ComparerConverter calls the fn's own IComparer, or reads a Boolean as less-than
  • SortArray orders through Enumerable.OrderBy and copies back into the caller's array
  • Tests cover both comparator kinds, stability, and the array argument

ComparerConverter mapped a bool result to 1 or 0 through ConvertToInt, so
it could never answer "less". It now calls the fn's own IComparer, or reads
a Boolean as less-than.

SortArray orders through Enumerable.OrderBy, which is stable, and copies
the ordered elements back into the array it was given, so sort keeps
sorting an array argument in place.
@skydread1 skydread1 self-assigned this Aug 20, 2026
@skydread1
skydread1 merged commit 7a8ef1b into maint-1.11.x Aug 20, 2026
3 checks passed
@skydread1
skydread1 deleted the fix/sort-comparator-predicate branch August 20, 2026 04:08
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