Skip to content

Add line sorting to string utils - #835

Merged
veler merged 6 commits into
DevToys-app:mainfrom
micahmo:feature/line-sorting
Jun 8, 2023
Merged

Add line sorting to string utils#835
veler merged 6 commits into
DevToys-app:mainfrom
micahmo:feature/line-sorting

Conversation

@micahmo

@micahmo micahmo commented Jun 5, 2023

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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

@veler veler left a comment

Copy link
Copy Markdown
Collaborator

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