-
-
Notifications
You must be signed in to change notification settings - Fork 981
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
Fix 1164 wikivoyage sorting #19858
Fix 1164 wikivoyage sorting #19858
Conversation
…" show "London" on the 5 place
public void sortSearchResults(@NonNull List<WikivoyageSearchResult> results, String searchQuery) { | ||
String searchQueryLC = searchQuery.toLowerCase(); | ||
results.sort((sr1, sr2) -> { | ||
int sr1Comparison = collator.compare(sr1.getArticleTitle(), searchQuery); |
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.
getArticleTitle() we can store in local variables
} else { | ||
String title1LC = sr1.getArticleTitle().toLowerCase(); | ||
String title2LC = sr2.getArticleTitle().toLowerCase(); | ||
if (title1LC.contains(searchQueryLC) && !title2LC.contains(searchQueryLC)) { |
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.
result from contains also store in boolean variables
int sr2Comparison = collator.compare(sr2.getArticleTitle(), searchQuery); | ||
|
||
if (sr1Comparison == 0 && sr2Comparison != 0) { | ||
return -1; |
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.
comparator should always return Integer.compare or String.compare methods to avoid in consistency, this comparator should be rewritten without ifs !=, check Search results comparator
case CONTAINS_OF_TITLE: | ||
if (sr1Comparison != 0 || sr2Comparison != 0) { | ||
if (sr1Comparison || sr2Comparison) { |
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.
not correct compare method
0fed150
to
4118fd3
Compare
No description provided.