New plugin: Obsidian Custom Sort

for my personal purposes I’ve created a plugin which allows for full control over the order of files and folders in Obsidian File Explorer. Order is specified in YAML in front matter. Each folder can have its own ordering logic, or can stay with the Obsidian standard sorting. You can use sorting and grouping rules or direct order specification by listing names (wildcard supported). Or mix and match.

I’ve been using this plugin for some weeks already and it looks like it nicely fills the gap of the missing feature of (which I love at first sight BTW!)

And already added new feature, as per users request.

See if it fits your needs as well, your feedback is welcome, also regarding the documentation


Hi Sebastian, I just installed your plugin now, and while it was working amazingly at first, I’ve now run into a little issue. For some reason, I can’t set a custom sort order for just one of the folders in my vault. The plugin works perfectly fine for everything, except for the final folder (titled Transformation) you can see in my screenshot. I’ve tried a bunch of different things and for the life of me I can’t get it to change from its default a-z sort. Any help would be greatly appreciated.

I’m on an iPad Pro M1 11"

I’m also wondering if there’s a workaround for custom sorting in folders with identical names, but which are themselves inside different folders. E:g I have folders named ‘Basic’ and ‘Advanced’ in both my ‘Principles’ and ‘Skills’ folders, meaning I have two folders named ‘Basic’ and two folders named ‘Advanced’. Currently, if I try to set a custom sort order for both the plugin refuses to run due to identical folder names. Is there some way to specify which of the two folders I mean, e.g by writing target-folder: Basic/Skills or something of the sort (i know this specific example doesn’t work)? Of course the current workaround is to rename the folders to ‘Basic Principles’ and ‘Basic Skills’, but I’m wondering if there’s a solution within the plugin for this.

Unfortunately it’s now broken down for everything except first-order folders (it works for folders within root, but not for the folders within those folders). I can’t spot any formatting errors in the sortspec document so I really don’t know what’s going on.

Hi @Drinkaholik,
the target-folder: in the simplest form treats its parameter as a full path to a folder.
For example:

  • target-folder: Principles refers to a folder named Principles at root level of the vault
  • target-folder: Basic refers to a folder named Basic at the root level of the vault
  • target-folder: Principles/Basic refers to a folder named Basic which is a child of the Principles

For your specific case visible on the screenshot you can use the full paths as below, respectively:

  • target-folder: Principles
  • target-folder: Principles/Basic
  • target-folder: Principles/Advanced
  • target-folder: Principles/Advanced/Transformation
  • … and so on.

If I understand your example correctly, this should help.

You can also specify target folder by the name only (with some additional syntax), yet if in your vault there are multiple folders with the same name (which is exactly your case) that method would be more confusing than helpful.


Thank you so much! Both for the quick (and comprehensive) reply and for making this amazing plugin. It’s all working perfectly now.

My bad for not noticing that feature in the readme until now :sweat_smile:

1 Like

Hi @SebastianMC , thank you for the plugin. I would like to custom sort my files by date from the nearest to the oldest in the format of MM/DD/YYYY. I’ve turned on the custom sort toggle button and added the following in sortspec, but the sorting was out of order. --- sorting-spec: | target-folder: folder with-metadata: publishTime order-desc: a-z by-metadata: publishTime --- In each of the file I have metadata publishTime as the following: ---publishTime: 12/25/2017--- Any idea how to work around it? Appreciate your help

1 Like

Hi @upcrown ,

while the YAML format (used for frontmatter metadata) itself supports data types and supports explicit type annotations, it looks like Obsidian (at least for now) treats all values as strings (or collections of strings, etc.)

That means, even if you enforce a specific type of the metadata:

publishTime: !date 08/02/2022
birthday: !date 2020-10-11
timeoftheday: !timestamp '2023-02-07T08:30:00Z'

it is seen by Obsidian YAML parser as string, hence sorted as string.

Having the above in mind, my suggestion for now is to use a different date format in the metadata, a format which can be still sorted properly if treated as a string.

Your example uses the US date format, which is unfriendly for text-based sorting :slightly_smiling_face:

Could you switch to ISO-alike format, where the year comes first, then month (as a number) and then the day? For example:

publishTime: 2017-12-25

This would resolve the sorting issue automatically.

If switching the date format is not feasible (for various potentials reasons), there is no simple way to sort correctly by the dates in US format (in a metadata or as part of file name) because all is string-based.

Long-term many solutions are possible on the plugin side and/or on Obsidian side

Short term: please open a new discussion in the plugin github home. Handling dates is tricky, because of the various date formats. My thinking is towards some explicit specification in sorting-spec that a metadata contains a date (or a timestamp) plus (optionally) about the date format (taking the locale as the default).

To recap: for now, the only way to sort by dates in metadata correctly is to use date format that allows text-based sorting, e.g. YYYY-MM-DD or YYYY/MM/DD or equivalent.


Thank you @SebastianMC , after switching to the YYYY-MM-DD format, it works perfectly!

Hi @SebastianMC apologies for replying to this thread but I’m struggling to figure out if what I want to do is possible. the > is without the quotes as it was trying to format it.
I have a sort spec with the below

sorting-spec: |
target-folder: 2. Oneshots
‘>’ a-z
target-folder: 2. Oneshots/*

i have a note in each subfolder of 2. Oneshots that is called the exact same as the folder. Is it possible to get this file first or do i have to write out each folder individually?

Any help is greatly appreciated.

Hi @RevenantsEmbrace,

I’ve copied your question to the discussions section of the custom-sort plugin home on gitgub. It provides more context and could be helpful for others. The question is related to the macros feature of custom-sort.

The solution is to use the macro {:%parent-folder-name%:} as below:

sorting-spec: |
  target-folder: 2. Oneshots
  > a-z
  target-folder: 2. Oneshots/*

The macro {:%parent-folder-name%:} gets expanded to the exact name of the target folder (which is logically the parent folder for the sorted items). In result, notes with the name matching target (parent) folder will be pushed to the top. The remaining items in the folder will be sorted using default < a-z.

If you wish, you can explicitly specify the sorting order for the remaining items in subfolders with the indented spec like:

sorting-spec: |
  target-folder: 2. Oneshots
  > a-z
  target-folder: 2. Oneshots/*
    > a-z

This will sort items in subfolders with the specified reverse alphabetical order

BTW one of oncoming releases of this custom-sort plugin will apply the Obsidian-UI selected sorting as the default, when unspecified in spec, for the remaining items in a folder

@SebastianMC I may have missed it but is it possible to sort .md files first? I have a mix of notes and assets in folders but would like the notes at the top.

Hi @m1k3

by default the plugin matches against file names, ignoring the extension.
At the same time you can match against full file names, including the extension. In that case the explicit syntax has to be used.
For example, to match all files with the .md extension you can use:

  • the token /:files. tells the plugin to match against file name with extension
    • for clarity, there is a sibling token /:files which takes the file name w/o extension, for matching
  • the token ... (three dots) is a wildcard which matches any text
  • the text .md matches obviously the file extension
  • notice that there are 4 dots in the expression:, because it is a concatenation of the two above tokens

Not knowing your specific usage scenario, an example sorting specification could look like:

sorting-spec: |
  target-folder: /
    > modified
  /:files. ....jpg
    > created

The above example spec:

  • puts the .md files in the top, ordered by modified date descending, which means recently modified go first
  • then go all folders
  • then go the JPG files (.jpg file extension) sorted by creation date descending (newer go first)
  • and, by design, all other files go below

In the anniversary of reaching the official Obsidian Community plugins, I’ve added a new major feature to Custom File Explorer Sorting

The 2.0.2 release brings support for drag and drop ordering of File Explorer items via Bookmarks integration:

This new feature was much requested, based on user’s feedback I’ve received. At the same time, it doesn’t interfere with the more advanced configuration-based sorting specifications and can coexist within the vault, even within the same folder. More details in the documentation to come

Drag and drop ordering simplest example


This is almost exactly what I came here to do. I found this page via web search. Now I just need to figure out how to install an extension… lol

Thank you for your efforts on this project.

Hi Sebastian, has there been any breaking Obsidian Updates on your side for the plugin ?
It still works on my end, but the options in the file menu have disappeared. My custom order hasn’t changed, and I can still turn it on and off, but I simply can’t add any new folder/file to it and rearrange them.

Thanks in advance

Hi @irv.rhingo,

please go to home of the plugin on github, to issues section or discussions and see if the specific incorrect behavior which you observe hasn’t been already reported and addressed.

As for now, there are no open bugs or incompatibilities.

So far there were three or four releases of Obsidian with breaking changes, which required updates of the plugin. And indeed some of the Obsidian breaking changes prevented the context menu from appearing and/or working correctly. At the same time, the the plugin is kept backward compatible after each update.

The quickest way would be to update the plugin (2.1.9 is the newest release for now) and see if it helps. If the problem persists, please report a new ticket in issues and include the details like platform, versions (Obsidian, plugin), screenshots, etc. Some of the scenarios are tricky.