Sorting on dataviewjs has humbled me

thought I was a bit higher than a beginner user and the last couple of days has humbled me. Just want to sort my query results of filenames in an ascending order in a dataviewjs. Note that I am working with files other than MD so dataview does not work

What I’m trying to do

the query (below) works perfectly BUT the results don’t come out in ascending order. My filenames start with numbers and then alpha, e.g. 0006 language, 0008 authors, 009 checklist etc

dv.header(2, ‘Abstract’)
const pdfFiles = app.vault.getFiles().filter(file => file.path.includes(‘GARRAWALI/PHDDD/phdddComponents/010 ABSTRACT’))
dv.list( => dv.fileLink(file.path)))

Things I have tried

Have worked through a few examples on this forum … using .sort(p =>, “desc”) in various places in query but never works

got a feeling i’m missing (or have forgotten) something tiny like a dot or a placement … would really appreciate support if anyone is awake on this sunday morning

I’m no expert on this, but I’ve cobbled together some working scripts with much help from others on this forum. Here’s an example of how I grab a bunch of files and then sort them:

const docFiles = app.vault.getFiles()
    .filter(file => file.path.includes(docpath) &&
    .sort( (a, b) =>

Hopefully this applies to what you’re trying to do and can be of some assistance.

1 Like

thankyou … evaluation error comes up and says that sort is not a function … although query works fine when the sort line is not there

I would think this would work, it’s basically the way I include files in the footer script that I include in all my journals:

const pdfFiles = app.vault.getFiles()
	.filter(file => file.path.includes('GARRAWALI/PHDDD/phdddComponents/010 ABSTRACT'))
	.sort((a, b) =>
if(Array.isArray(pdfFiles) && pdfFiles.length){
    dv.list( => dv.fileLink(file.path)))
1 Like

Very, very beginner here andn need help.

I have this very simple Habit Tracker, but it is not sorting the entries in the table by date. Any clues?

yoga as 🧘‍♀️,  
swimming as 🏊,
art as 🎨,  
gratitude as 💗,  
meditation as 🧠, 
journalling as 📝,
sleep as 💤,  
mood as mood,
HRV as 📈

FROM "Journals"


When I include this line, it doesn’t show any data at all.

Please help!

FROM “Journals”

WHERE <= date(now) AND >= date(now) - dur(7days)

worked perfectly, thankyou for taking the time!

1 Like

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