Skip to content
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

Natural string comparer #38

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Conversation

StephenCleary
Copy link
Owner

@StephenCleary StephenCleary commented Mar 24, 2022

It may be better (although possibly less efficient) to split up the current situation more:

  1. Define a splitter that parses a string into (ReadOnlyMemory<char>, IsNumeric) splits.
  2. For sequences of the splits, define a comparer.
  3. The provided implementation of this comparer would be a composite comparer: one for numeric splits and one for non-numeric splits.

This would allow several extension points not currently possible with the current PR:

  1. By providing a custom splitter and a custom numeric split comparer, decimals and/or negative numbers could be supported.
  2. By providing a custom non-numeric split comparer, any kind of (sub)string comparer logic could be supported (currently, we are limited to StringComparison). E.g., handling spaces differently.
  3. By providing a custom composite comparer, the user can change the ordering when a numeric split is compared with a non-numeric split.

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.

None yet

1 participant