Reverse number bibliography?

Hello,

I am trying to create a bibliography in this order:

3. Citation, 2017
2. Citation, 2010
1. Citation, 1997

The style I am using (based on Cell) currently outputs:
1. Citation, 2017
2. Citation, 2010
3. Citation, 1997

It seems like this question has already been asked:
https://forums.zotero.org/discussion/comment/99189
But, I cannot find anything in Zotero or in CSL documentation as to how to do this. Apologies if this has already been answered somewhere - I am a CSL newbie and learning to do this for a faculty member.

Much thanks for any assistance,

Donna
  • I'm afraid this still isn't possible
  • edited April 13, 2018
    Oh no! :(
    OK - I will make do. This would be a great thing to incorporate!

    Thanks for your reply and for considering,
    Donna
  • edited April 13, 2018
    It might be possible. Give this a try:

    https://github.com/citation-style-language/test-suite/blob/master/processor-tests/humans/sort_BibliographyCitationNumberDescendingViaMacro.txt

    The trick seems to be wrapping citation-number in a macro, then using that as the sort key.
  • Thanks! That doesn't seem to be working, but I think I may need to edit a few other things first. I'll keep trying - that definitely sounds like it *should* work! Thank you!
  • If you get stuck, free to paste your code to https://gist.github.com, and post the saved URL back here. Happy to take a look.
  • Thanks for your help! It seems that switching between "ascending" and "descending" changes the list by date, but not by number.

    Here's my code, apologies in advance for the sloppiness - I think I implemented your suggestion properly - apologies if I made a mistake!

    https://gist.github.com/dtwrub/1ea15dc9ea1fd8abd412917289ecab4c
  • Try moving the citation-number macro call to the last position in the bibliography sort block, and setting the other keys also to sort="descending".
  • edited April 13, 2018
    Actually you don't want descending on the other elements do you, sorry. Just moving the citation-number macro to last position should do it.
  • edited April 13, 2018
    :O :O : !!! That worked! Actually, I nuked everything else and added a date sort, as I don't need it sorted by anything else. This did exactly what I needed:

    I added your code:

    <macro name="citation-number">
    <text variable="citation-number"/>
    </macro>

    and then changed the sort:

    <bibliography>
    <sort>
    <key macro="issued" sort="ascending"/>
    <key macro="citation-number" sort="descending"/>
    </sort>
    ...

    </bibliography>

    And it's perfect! I was unaware that the *order* of the keys in the sort block made a difference... my newbie is showing :)

    Thank you SOOOO MUCH for your help - this is going to help a number of people I work with!!!

    Have a great weekend!!
  • Great! If you wrap your samples in <code></code> tags, it will become visible.
  • Thank you!!! I just did that - I hope it's viewable now? (I looked at the source code for this page to see how you did it :P )

    Thank you again!! :) :) :)
  • And yes, sorting behavior can be a mind-bender. It looks like call-via-macro is a hack I coded into the processor years ago in more adventurous days, on the off chance that it would one day prove useful. Glad to find it's seeing service!
  • YES! Thank you so much!!! :)
  • For posterity, and by way of documentation, what's happening there is that calling citation-number via macro has no effect on the sort, but only changes the order in which numbers are applied to the entries.
  • Right - which is why that needs to be last, and whatever sort you really want needs to be applied first - in my case, year of publication?
  • Yep, that's it exactly.
  • Excellent - got it! Thank you again so much!!
  • @dtwrublewski: There will be a change in the way citation-number works as a sort key from processor release 1.1.242. When used as a primary key in cs:bibliography with sort="descending", whether as a variable or via a macro, citation-number will reverse the order of citations, with the highest citation-number at the top of the listing. When used as a secondary key in cs:bibliography with sort="descending" whether called as a variable or as a macro, citation-number will reverse the numbering of citations without affecting a stable primary sort.

    I don't think this will alter the results from the structures covered in this thread: the only change is to eliminate the strange and wonderful difference between macro and variable calls to citation-number in cs:key. But just in case.
Sign In or Register to comment.