Sorting by the most recent mention in dataview

What I’m trying to do

I’m trying to create a Dataview table in which elements are sorted according to how recently they were mentioned in another note. That is…I’m trying to sort by the created date (or modified date) of the most recently created note backlinking to the given note in the Dataview table

Also, how do I get the length of the groups that are found?

I’ve added in comments in the code below in the two spots where I’m having trouble

Things I have tried

Right now, I’m only able to get an array with the inLinks for a given row. But I can’t seem to treat these array elements as files (so I can’t access their file.ctime file.mtime). All I’ve been able to do is to get the length of the array containing the inlinks. So for now I’m sorting by the number of InLinks.

// HOW CAN I CHANGE THIS FUNCTION TO RETURN THE MOST RECENT INLINK DATE?
function InLinksDate(k){
	var y = k.file.inlinks.length
	return(y)
}

for (let group of dv.pages('"#Books"').groupBy(p => p.genre)) {
    // WHAT CAN I REPLACE THE SECOND GROUP.KEY WITH TO GIVE THE LENGTH OF THE GROUP?
    dv.header(3, group.key + "  " + group.key);
    dv.table(["Name", "Genre", "Most Recent Mention"],
        group.rows
            .sort(k => k.file.inlinks.length, 'desc')
            .map(k => [k.file.link, k["circle"], InLinksDate(k)]))
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.