I need help with my CSL code for a sorted bibliography

edited August 16, 2023
I have tried to sort my bibliography in APA style by type but for some reason it does not work and my biblio is not sorted. Here is the code i have tried can someone please tell me where i went wrong ?

</macro>
<macro name="sort by type ">
<choose>
<if type="book chapter" match="any">
<text value="1"/>
</if>
<else-if type="article" match="any">
<text value="2"/>
</else-if>
<else-if type="thesis" match="any">
<text value="3"/>
</else-if>
<else-if type="article-journal article-magazine article-newspaper" match="any">
<text value="4"/>
</else-if>
<else-if type="webpage" match="any">
<text value="5"/>
</else-if>
<else/>
</choose>
</macro>
<citation et-al-min="3" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" collapse="year" givenname-disambiguation-rule="primary-name-with-initials">
<sort>
<key macro="author-bib" names-min="3" names-use-first="1"/>
<key macro="date-sort-group"/>
<key macro="date-sort-date" sort="ascending"/>
<key variable="status"/>
</sort>
<layout prefix="(" suffix=")" delimiter="; ">
<group delimiter=", ">
<text macro="author-intext"/>
<text macro="date-intext"/>
<text macro="citation-locator"/>
</group>
</layout>
</citation>
<bibliography hanging-indent="true" et-al-min="21" et-al-use-first="19" et-al-use-last="true" entry-spacing="0" line-spacing="2">
<sort>
<key macro="sort by type"/>
<key macro="author-bib"/>
<key macro="date-sort-group"/>
<key macro="date-sort-date" sort="ascending"/>
<key variable="status"/>
<key macro="title"/>
</sort>
  • Use macro names entirely without spaces (so sort-by-type) I don't think spaces are technically illegal, but a bad idea and in your case you have an extra space in the macro name that definitely breaks the macro call in sort
Sign In or Register to comment.