File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,22 @@ const publications = ref([])
9
9
10
10
onMounted (async () => {
11
11
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
+ })
13
28
})
14
29
</script >
15
30
You can’t perform that action at this time.
0 commit comments