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 natural sort functions for wxString #1923
Conversation
…idgets into natural-sort
Add a new string fragment type for whitespace and punctuation which needs to be assessed separately from letters and symbols. Use wxUint64 instead of long for storing the value for numeric fragment. Use collate instead of compare for non-numeric fragments. Change names for the public comparison functions: wxWidgets provided function is now named wxCmpGenericNatural() and for common public use is wxCmpNatural() which calls a native function in wxMSW and wxCmpGenericNatural() elsewhere. Make some other changes to simplify and possibly speed up the code.
In src/arrstr.cpp add wx/utils.h and wx/wxcrt.h includes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks broadly good to me and the remaining small changes should be very simple to make.
Concerning wxUSE_REGEX
, I think it would be fine to just fall back on wxStrcmp()
in this case, we just would need to mention this in the documentation (and also disable unit test, i.e. add a warning about skipping it, in this case).
Thanks again for reviving this, it would be nice to finally see it merged!
I may be missing something here, but why are you so pessimistic about the chance of this being merged? I don't see any really bad problems with these changes. Of course, they're not perfect, but then nothing is and things could be improved later, while for now this already adds a wrapper for a useful (in the context of UI development) MSW function with a reasonable fallback under the other platforms, so I think it should be fine to merge it... Unless, once again, I simply oversaw some critical problem? |
My innate pessimism aside, the issues I see (none is critical):
Anyway, I will address the issues pointed in the review, hopefully by Tuesday at the latest. |
"$" is not considered a letter/symbol, but a punctuation.
In wxCmpNaturalGeneric() do not use wxStrcmp() which requires including wxcrt.h; use wxString::compare() instead. In the wxCmpNaturalGeneric() documentation, fix the typo in wxRegEx (was wxRegex) and do not refer to undocumented wxStrcmp().
I have addressed the review comments, please let me know if there something more to be done here. |
Looks good to me, I'm ready to merge this once the CI builds finish. Thanks again! |
You probably have a plan for this but I wonder how to merge it? I think, if possible, it would be best to somehow squash it into just two commits: the first containing all the commits by Rocketmagnet, the second with all mine. EDIT |
If wxRegEx is not available, do not just make a simple string comparison but perform a case-insensitive collation.
I have addressed the comments from the last review. |
Add natural sort functions. See #1923
Thanks again, I've squash-rebased as suggested and pushed it now. |
This PR builds on #780, attempting to fix some possible deficiencies in that PR.
I have not updated the documentation yet, as this PR may be rejected for the reasons stated in my last comment in #780.
The code also needs to account for
wxUSE_REGEX == 0
but I do not know how to best do it.