Skip to content

Add isSorted and related matchers #2490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

AgamAgarwal
Copy link

@AgamAgarwal AgamAgarwal commented Apr 25, 2025

Add sorting related matchers for iterables.

  • isSorted
  • isSortedUsing
  • isSortedBy
  • isSortedByCompare

These match the functions available in https://github.com/dart-lang/core/blob/main/pkgs/collection/lib/src/iterable_extensions.dart


  • [✅ ] I’ve reviewed the contributor guide and applied the relevant portions to this PR.

@AgamAgarwal AgamAgarwal requested a review from a team as a code owner April 25, 2025 10:25
@AgamAgarwal
Copy link
Author

Requesting one of the admins to take a look at this PR.

Copy link

github-actions bot commented May 6, 2025

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

@AgamAgarwal AgamAgarwal force-pushed the is_sorted branch 2 times, most recently from 5f77ab9 to e43a1d2 Compare May 7, 2025 15:36
@AgamAgarwal
Copy link
Author

Updated the code to fix the failures which came up in dart analyze.

This ensures that a single iteration happens.
This is also how iterable_extensions.dart implements the corresponding methods.

Also, rename the parameter from `comparator` to `compare` to match those functions.
@iinozemtsev iinozemtsev requested a review from lrhn May 9, 2025 14:11
Copy link
Member

@lrhn lrhn left a comment

Choose a reason for hiding this comment

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

It looks fine to me.
I'm not an owner of/expert on the test package, so we'll need one of those too.

This will give more information about where the actual mismatch happened.
Handle errors from keyOf and compare functions and construct the mismatch description
accordingly.
@lrhn
Copy link
Member

lrhn commented May 28, 2025

@dart-lang/core-package-admins We need someone with actual test-package experience to review this too.

@lrhn lrhn requested a review from biggs0125 May 28, 2025 17:19
@biggs0125 biggs0125 requested review from natebosch and removed request for biggs0125 May 28, 2025 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants