Table not sorting after the date created and name of the file

Things I have tried

What I’m trying to do

Here is my dataview code:

Table Date AS "Date created", Tags AS "Tags", Subject AS "Subject"
FROM "2. Notes 📝/DMA"
Sort file.cday asc, desc 

and below is how it looks on the table. Everything before this points is sorted.

This is difficult to understand.
What’s your file.cday column?
You define in the query the field Date… We can guess this is a field in your frontmatter, but we don’t see it (to check the syntax, etc.). We don’t see if Date is a real date or a simple string.
Is file.cday different from Date?
About the, attention to the use numbers as prefix for strings: they’re considered as strings, not as numbers. This means: alphabetic order checks character by character (as strings)- For example 25 - Combinatoric.. checks the “2”, then the “5”, …, not the “25”.

Okay I see your point.
Is there anyway to sort it so that it considers the filename as whole string?

I also forgot to mention that “Date” is form the yaml tags for example:

Date: 01-11-2022

1 - you want to sort by file.cday or by Date?
2 - to Date be considered a real date, you need to follow the right format: YYYY-MM-DD, i.e., Date: 2022-11-01
3 - is considered as whole string! I just point to the fact if you see 11 - something before 2 - title it’s the normal behavior to alphabetic order in strings (because in the case it doesn’t “see” the “2” and the “11” as numbers)
4 - if all your file names start with a number and you want sort the results by that number (ignoring the rest), then I think that is possible. (check this example: Dataview does not sort files by name - #2 by mnvwvnm)

I think I am opting to use solution 4 as that would make most sense. The reason that I am using date is so that I can use the dd-MM-yyyy format as that I don’t like the alternative.

Thank you for your help!

You can format the output of a valid date in ISO format.
For example, try dateformat(file.cday, "dd-MM-yyyy") AS "My date".
You can also format the output of any date (all dates in dataview results) in settings > dataview:

(in you case, you can change to dd-MM-yyyy)

Search for Luxon tokens in web.

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