SebastianMC / obsidian-custom-sort

Take full control over the order and sorting of folders and notes in File Explorer in Obsidian
GNU General Public License v3.0
252 stars 19 forks source link

automatic sorting #112

Closed ilteris closed 7 months ago

ilteris commented 7 months ago

When I change a file why does the sorting not applied? My sorting spec is below.

`

sorting-spec: | order-desc: modified

`

I always have to apply it manually to fix the sorting. Is this working as expected?

SebastianMC commented 7 months ago

Hi @ilteris

TL;DR

The file explorer events like: file/folder creation/addition/duplication or file/folder move/rename trigger the (re)sorting automatically and unconditionally. This is a standard Obsidian behavior, applicable also to custom sorting.

At the same time, modifying the content of a file only triggers the (re)sorting if the option Modified time (new to old) or Modified time (old to new) is selected in Obsidian standard sorting UI. This also applies to custom sorting. The UI selected sorting Modified ... enables the continuous monitoring of notes content changes and triggering of sorting (whatever sorting you have configured)

Background and more details

Obsidian triggers sorting automatically in the scenarios described in TL;DR section above.

From the practical standpoint, if you want the sorting to be applied and re-executed immediately after each change of any file or note, in the Obsidian UI for standard sorting select the option Modified time (new to old) or Modified time (old to new). This will cause Obsidian to re-apply the sorting (whatever it is) immediately after each change. For example: you type three characters in a note, take a breath, and all items in File Explorer will be (re)sorted and will reflect the change you made. If you are editing a longer text, after every pause in typing (a second or so, based on observations) the sorting will be re-executed. This is how Obsidian works by design when the Modified time (...) is selected in UI. It also applies to custom sorting.

If you want to keep this automatic triggering of sorting and at the same time prevent the Modified time (new to old) or Modified time (old to new) to be applied, use the custom sorting specification for all (or selected) folders to apply the desired order, including the standard sorting orders. If you need help with that, let me know.

On top of that, if you want to recompile the sorting specification and apply it, you have four options:

  1. Click the ribbon toggle icon twice, to suspend and re-enable the custom sorting
  2. Execute the 'sort-on' command from command palette
  3. Click a keyboard shortcut (aka hotkey). Prior to that you should assign a hotkey to the 'sort-on' command in 'Hotkey' settings
  4. From the File Explorer menu, on any folder or file, choose Custom sort: > apply custom sorting

I hope it clarifies and helps!