How to sort dataviewjs query

Hi,

I have this bit of very nice code I found on this forum, my apologies to the creator for not attributing you, I forgot where I found it. But my thanks, to whoever it was.

dv.table( ["Day", "Tasks"], dv.pages('"Notes/2024/2024-06"') .map(d => [ d.file.link, '✔'.repeat(d.file.tasks.filter((t) => t.checked).length) + '❌'.repeat(d.file.tasks.filter((t) => !t.checked).length) ] ) )

My problem is I would like it to sort on the first field (filename). How can I do this?

Thanks!

I was able to figure it out with the help of this site:

Much easier than I thought, but I must admit that I do not know why it works, but it does!

dv.table( ["Day", "Tasks"], dv.pages('"Notes/2024/2024-06"') 
	.sort(d => d.file.link)
	.map(d => [ d.file.link, '✔'.repeat(d.file.tasks.filter((t) => t.checked).length) + '❌'.repeat(d.file.tasks.filter((t) => !t.checked).length) ] 

	) )

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