Sorts first-author last name matches first when year present. (#3025)
Closes #3024
This commit is contained in:
parent
94f5f7a3c4
commit
d6a9b43515
1 changed files with 10 additions and 7 deletions
|
@ -505,6 +505,7 @@ var Zotero_QuickFormat = new function () {
|
|||
await Zotero.Items.loadDataTypes(items);
|
||||
|
||||
searchString = searchString.toLowerCase();
|
||||
let searchParts = Zotero.SearchConditions.parseSearchString(searchString);
|
||||
var collation = Zotero.getLocaleCollation();
|
||||
|
||||
function _itemSort(a, b) {
|
||||
|
@ -513,13 +514,15 @@ var Zotero_QuickFormat = new function () {
|
|||
// Favor left-bound name matches (e.g., "Baum" < "Appelbaum"),
|
||||
// using last name of first author
|
||||
if (firstCreatorA && firstCreatorB) {
|
||||
let caStartsWith = firstCreatorA.toLowerCase().indexOf(searchString) == 0;
|
||||
let cbStartsWith = firstCreatorB.toLowerCase().indexOf(searchString) == 0;
|
||||
if (caStartsWith && !cbStartsWith) {
|
||||
return -1;
|
||||
}
|
||||
else if (!caStartsWith && cbStartsWith) {
|
||||
return 1;
|
||||
for (let part of searchParts) {
|
||||
let caStartsWith = firstCreatorA.toLowerCase().startsWith(part.text);
|
||||
let cbStartsWith = firstCreatorB.toLowerCase().startsWith(part.text);
|
||||
if (caStartsWith && !cbStartsWith) {
|
||||
return -1;
|
||||
}
|
||||
else if (!caStartsWith && cbStartsWith) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue