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

Add line sorting to string utils #835

Merged
merged 6 commits into from
Jun 8, 2023

Conversation

micahmo
Copy link

@micahmo micahmo commented Jun 5, 2023

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • New feature or enhancement
  • UI change (please include screenshot!)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Internationalization and localization
  • Other (please describe):

What is the current behavior?

Issue Number: #232

What is the new behavior?

Add the following functions to the string utilities tool. These operate on lines of text.

  • Alphabetize
  • Reverse alphabetize
  • Alphabetize by last word
  • Reverse alphabetize by last word
  • Reverse
  • Randomize
DevToys-Alphabetize-Demo.mp4

Other information

All of the line splitting is done on CR (\r). I noticed that this is the line separator used for typed text and loaded files using any line endings (CR, LF,"or or CRLF). I don't really understand why, but it seems consistent.

For sorting by last word, I'm splitting on space and also comma (to accommodate CSV and last,first formatting).

It might be ever so slightly confusing that the "Original text" button is under the "Convert" heading. Maybe we could consider making it a highlighted/action button.

Quality check

Before creating this PR:

  • Did you follow the code style guideline as described in CONTRIBUTING.md
  • Did you build the app and test your changes?
  • Did you check for accessibility? On Windows, you can use Accessibility Insights for this.
  • Did you verify that the change work in Release build configuration
  • Did you verify that all unit tests pass
  • If necessary and if possible, did you verify your changes on:
    • Windows
    • macOS (DevToys 2.0)
    • Linux (DevToys 2.0)


viewModel.RandomizeCommand.Execute(null);

// Can't guarantee the order, just make sure everything is still there
Copy link

Choose a reason for hiding this comment

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

An interface could be introduced, then we could mock and guarantee results, something like https://stackoverflow.com/a/311829/17052649 if that's acceptable.

Copy link
Author

Choose a reason for hiding this comment

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

Not a bad idea. I hadn't dived into how DI is set up, so I wasn't sure if I could inject the real Random though the constructor. Also thought it might be a bit overkill. I guess I'll leave this one up to the maintainer.

@veler veler linked an issue Jun 5, 2023 that may be closed by this pull request
Copy link
Collaborator

@veler veler left a comment

Choose a reason for hiding this comment

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

Approved. Thank you again for this improvement!

@veler veler merged commit 14a9f06 into DevToys-app:main Jun 8, 2023
@micahmo micahmo deleted the feature/line-sorting branch June 8, 2023 02:51
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.

Sort lines of text alphabetically
3 participants