Sorting citation items by year-suffix

This problem is originally from https://github.com/zepinglee/citeproc-lua/issues/45 and I simplify it to the fixture (https://gist.github.com/zepinglee/4a3a2de7e671a1d8cff86897b75b3b84). I’m planning to sort the citations items with output (Nietzsche 1988a, 1988b) but citeproc-js gives (Nietzsche 1988a, 1988b). How can I sort cites with the year-suffix?

If I enable debugging (citeproc-js/src/registry.js#L803-L805), the processor prints the following log. It seems that year-suffix is not involved in the procedure of citation sorting and the cites are outputted in the order that they are cited. Is this the expected behavior?

[test_Test] sort keys (bibliography_sort): Nietzsche|Friedrich|,119880000100000000|,Title|B|of|ITEM-1|
[test_Test] sort keys (bibliography_sort): Nietzsche|Friedrich|,119880000100000000|,Title|A|of|ITEM-2|
[test_Test] sort keys (citation_sort): Nietzsche|,119880000100000000|
[test_Test] sort keys (citation_sort): Nietzsche|,119880000100000000|

I also compare apa.csl with biblatex-apa (https://gist.github.com/zepinglee/157bbf15b4a52b149ded753060b5bf47). The former outputs (Nietzsche, 1988b, 1988a) and the latter outputs (Nietzsche, 1988a, 1988b).

Sorry, I’m a bit confused. In your first post, you write

I’m planning to sort the citations items with output (Nietzsche 1988a, 1988b) but citeproc-js gives (Nietzsche 1988a, 1988b).

Those are the same thing?
Then in the text fixture with APA, you say

I also compare apa.csl with biblatex-apa. The former outputs (Nietzsche, 1988b, 1988a) and the latter outputs (Nietzsche, 1988a, 1988b).

But assuming that apa.csl is the former, that’s not actually what the text fixture shows:


>>===== RESULT =====>>
>>[0] (Nietzsche, 1988a, 1988b)
<<===== RESULT =====<<

Just taking your question as ‘how can I sort by year-suffix in the citation’ the answer is that per spec, year suffixes are in the oder items appear in the bibliography. Consequently, you can sort by year suffix by sorting citation the same way the bibliography is sorted.

The original question uses a style that doesn’t sort citations at all, as you note on GH, so the reverse sorting there is not an accident.

Sorry for my bad writing. I was expecting <key macro="date"> taking year-suffix into account.

Do you mean adding <key variable="title"/> in <citation>'s <sort> just like <bibliography>? Yes, it works!