Skip to content

Commit 63ab6a3

Browse files
committed
Update publication list sorting for year then first author last name
1 parent febd66a commit 63ab6a3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pages/publications.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,22 @@ const publications = ref([])
99

1010
onMounted(async () => {
1111
const response = await fetch('/assets/publications.json')
12-
publications.value = await response.json()
12+
const pubs = await response.json()
13+
14+
// TODO: update with better sorting when functionality added to UI
15+
// sort by year, then by first author (alphabetical)
16+
publications.value = pubs.sort((a, b) => {
17+
if (a.year !== b.year) {
18+
return b.year - a.year; // Sort by year in descending order
19+
}
20+
// Sort by first author alphabetically (last name)
21+
const aFirstAuthor = a.authors.split(',')[0]
22+
const bFirstAuthor = b.authors.split(',')[0]
23+
const aLastName = aFirstAuthor.split(' ').pop()
24+
const bLastName = bFirstAuthor.split(' ').pop()
25+
26+
return aLastName.localeCompare(bLastName);
27+
})
1328
})
1429
</script>
1530

0 commit comments

Comments
 (0)