Just a simple fix when I’m using multiple vaults would be to sort them in an alphabetical order instead of recent opened. I use a lot of Vaults, so it gets messy over time. I have to use another Vault to create a MOC list of vaults. On top of that it opens a random (recently used) vault on the start. So it’s not the best solution.
For example I have a vault containing 1 000 tarantula species with the relation to each other and recent publications about them, that is a sub-vault of my animal species vault. It’s not often used, but I want it to keep separated for the graph view. When I use it, it gets on top of the list and a little bit later it gets lost on the list.
I figured out the issue. I’m running Obsidian v1.8.10. The vault order is determined not by the timestamp in the map, but by the order of the keys in the map. So I had to adjust my script so instead of just setting the timestamp, it recreates the map so when I serialize to JSON, it keeps the new insertion order. Also the setting changes only apply to newly opened Obsidian windows so if I already have a vault open, I have to exit Obsidian and re-open it.
Here’s the nodejs script I used for mine. Just change configFilePath for your system:
const fs = require('node:fs');
const configFilePath = process.env.HOME + '/snap/obsidian/current/.config/obsidian/obsidian.json';
const configJson = fs.readFileSync(configFilePath);
const config = JSON.parse(configJson);
if (typeof config?.vaults === 'object') {
const list = Object.keys(config.vaults).map((id) => { return { id, path: config.vaults[id].path }; });
list.sort((a, b) => a.path.localeCompare(b.path));
// orders the vaults according to the order of keys in the vaults map, so recreate it
const vaults = {};
for (let i = 0; i < list.length; i += 1) {
const item = list[i];
vaults[item.id] = { ...config.vaults[item.id] };
}
config.vaults = vaults;
fs.writeFileSync(configFilePath, JSON.stringify(config));
}