Skip to content

Fix RankBy ranks for equivalent keys - #1111

Open
yousefissa wants to merge 2 commits into
morelinq:masterfrom
yousefissa:fix/rankby-equivalent-keys
Open

yousefissa wants to merge 2 commits into
morelinq:masterfrom
yousefissa:fix/rankby-equivalent-keys

Conversation

@yousefissa

@yousefissa yousefissa commented Oct 15, 2026 •

Copy link
Copy Markdown

Fixes #826.

RankBy assigns different ranks to distinct source values whose selected keys compare equal. For example, ["aaa", "xyz", "aaaa"].RankBy(s => s.Length) returns [2, 3, 1] instead of [2, 2, 1].

Rank selected keys with the supplied comparer, then restore source order. Preserve descending ranks without gaps, deferred execution, and single source enumeration. Add regression coverage for equivalent keys, custom comparer ties through Rank and RankBy, nulls, and empty input.

Remove the internal dictionary getter left unused by this change.

Validation:

  • Six regression cases fail before the fix; all 19 focused rank tests pass afterward.
  • Full suite on .NET 10 Debug/Release and .NET 8 Debug: 2,393 passed per run, zero failures.
  • All library targets build in Release without warnings.

AI assistance: Codex assisted with implementation, tests, and review.

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.28%. Comparing base (d217ab1) to head (0301601).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1111   +/-   ##
=======================================
  Coverage   93.28%   93.28%           
=======================================
  Files         113      113           
  Lines        3439     3441    +2     
  Branches      969      971    +2     
=======================================
+ Hits         3208     3210    +2     
  Misses        215      215           
  Partials       16       16           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

RankBy and equivalent elements

1 participant