Sorting Dataviewjs by file size

I’m trying to manage the vast amount of attachments I currently have in my vault. I’d like to reduce the size if possible, so I’m trying to make a table of the attachments.

I’ve got the table up and running, but the sorting isn’t working as I’d like.

Currently I have this:

```dataviewjs
const nonMdFiles = app.vault.getFiles()
		.filter(p => p.path.includes('фSysteem/Bijlagen') && p.extension != 'md');


dv.table(["Bestand", "Bestandstype", "Bestandsgrootte"], nonMdFiles
		 .sort(p => p.stat.size, 'desc')
		 .map(p => [dv.fileLink(p.path), p.extension, Math.round(p.stat.size/1024,0) + " kb"]));

Bijlagen = attachments
Bestand = file
Bestandstype = file type
Bestandsgrootte = file size


I’ve also tried putting the “.sort” at the “const” part, so after ".filter. But that didn’t work either

I’d like to sort the file size from big to small.

Where is the error?

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