Skip to content

How the drag'n'drop ordering can coexist with config based sorting?

SebastianMC edited this page Oct 24, 2023 · 8 revisions

The drag and drop sorting via bookmarks integration (introduced in 2.0.2 release) doesn't exclude nor overwrite any of previous capabilities of the plugin.

It seamlessly integrates with what was there before. You can sort some files, some folders, a subset of files, etc. via drag and drop, and at the same time (even within the same folder) use sortspec files

Technically, the integration with bookmarks drag'n'drop injects on-the-fly the below sorting specification:

---
sorting-spec: |
  target-folder: /*
  bookmarked:
    < by-bookmarks-order
  sorting: standard
---

the specification is applied to each folder of the vault (target-folder: /*) unless an explicit sorting-spec: is used for the folder. It tells to collect bookmarked items in the top of a folder (bookmarked:) in the order reflecting bookmarks ( < by-bookmarks-order). Then goes the rest of files and folders (not bookmarked ones) ordered as selected in obsidian UI (sorting: standard).

An advanced example is to let bookmarks drag'n'drop control some files and folders in the middle of the File Explorer view of root folder, while some items above and below are steered via sortspec config:

---
sorting-spec: |
  target-folder: /
              // A special note containing list of recently modified and created notes - stays pinned in the top
  Recent notes   
              // Folder for notes and data requiring closer examination - let it stay in the top as well
  Inbox          
              // Then go files driven by the bookmarks drag'n'drop feature
  ↓ Items...
  bookmarked:
    < by-bookmarks-order
              // Below go meeting notes, sorted by modification date (recent go first)
  ↑ Items...
  /:files ...meeting notes
    > modified
              // Below go folders which name ends with a date in the format YYYY-MM-DD, ordered by creation date
  /folders ...\[0-9]\[0-9]\[0-9]\[0-9]-\[0-9]\[0-9]-\[0-9]\[0-9]
    > advanced created
              // Archive folder and Daily notes folder go in the bottom
  Archive        
  Daily notes
---

The inline comments explain the sorting configuration sections

The resulting order in demo vault could look like:

You can download the presented Demo vault 1.zip, unpack and examine it locally

IMPORTANT! To make the demo vault work after download, install and enable the two community plugins (they were intentionally excluded from the download)

  1. custom-sort <--- required for the custom sorting mechanics
  2. dataview <--- optional, it is used inside the note "Recent notes" to generate tables of recently modified and created notes