Make sort order using sortby more consistent#9747
Open
pmario wants to merge 2 commits intoTiddlyWiki:masterfrom
Open
Make sort order using sortby more consistent#9747pmario wants to merge 2 commits intoTiddlyWiki:masterfrom
pmario wants to merge 2 commits intoTiddlyWiki:masterfrom
Conversation
✅ Deploy Preview for tiddlywiki-previews ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Confirmed: pmario has already signed the Contributor License Agreement (see contributing.md) |
📊 Build Size Comparison:
|
| Branch | Size |
|---|---|
| Base (master) | 2487.2 KB |
| PR | 2487.4 KB |
Diff: ⬆️ Increase: +0.2 KB
⚠️ Change Note Status
This PR appears to contain code changes but doesn't include a change note.
Please add a change note by creating a .tid file in editions/tw5.com/tiddlers/releasenotes/<version>/
📚 Documentation: Release Notes and Changes
💡 Note: If this is a documentation-only change, you can ignore this message.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
sortbyfilter operator placing unlisted items first instead of lastSummary
The
sortbyfilter operator incorrectly placed items not present in the reference list at the beginning of the results instead of at the end. This is becauseindexOf()returns-1for unlisted items, which is smaller than any valid index, causing them to sort to the front.How to test
listfield containing:Alpha Beta GammaMyTag[tag[MyTag]sortby{MyList!!list}][tag[MyTag]sortby{MyList!!list}]Delta Epsilon Alpha Beta GammaAlpha Beta Gamma Delta Epsilon[tag[MyTag]sortby{MyList!!list}reverse[]]Gamma Beta Alpha Epsilon DeltaEpsilon Delta Gamma Beta AlphaExpected behavior: Listed items appear in the order defined by the reference list, and unlisted items appear at the end (in their original relative order). With
reverse[], the entire result is reversed.Compatibility Risk
Minimal — this is a single-operator fix in the sort comparator. Existing uses of
sortbywhere all items are present in the reference list are unaffected, sinceindexOf()never returns-1in that case.TODO
The release note needs a backwards compatibility notice too
Fixes: #8342