-
Notifications
You must be signed in to change notification settings - Fork 3
Revise entry sorting: refactor for readability, remove duplicates, sort rest alphabetically #52
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| accessing | ||
| sortEntries | ||
|
|
||
| entries sort: [:aEntry :bEntry | | aPriority bPriority | | ||
| aPriority := aEntry matchNarrowString: narrowString. | ||
| bPriority := bEntry matchNarrowString: narrowString. | ||
| aPriority = bPriority | ||
| ifTrue: [aEntry <= bEntry] | ||
| ifFalse: [aPriority >= bPriority]] | ||
| | seen | | ||
| entries sort: | ||
| [:entry | entry matchNarrowString: narrowString] descending | ||
| , [:aEntry :bEntry | aEntry <= bEntry ifTrue: [-1] ifFalse: [0]] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does the Or am I reading the syntax incorrectly?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, okay, |
||
| , [:aEntry :bEntry | (aEntry contents compare: bEntry contents caseSensitive: ECPreferences caseSensitive) - 2]. | ||
|
|
||
| "remove any duplicates" | ||
| seen := Set new. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't mind removing duplicates, as discussed in #39 , duplicates are just a side-effect of adding all selectors in the untyped model. How is performance though? First sorting, then converting into a Set sounds a bit expensive 🤔 |
||
| entries removeAllSuchThat: [:entry | | ||
| (seen ifAbsentAdd: entry contents) not]. | ||
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.
Huh, cool, no idea
#descendingworked onBlockClosure👍