obsidian-linter icon indicating copy to clipboard operation
obsidian-linter copied to clipboard

FR: Key sort should respect all levels

Open karmeye opened this issue 2 years ago • 4 comments

urls:
  website: ...
  blog: ...

If sort order settings is Asc Alphabetical, for example, the above would become:

urls:
  blog: ...
  website: ...

And so on for deeper levels.

Would also apply to lists, such as tags: .

I'm mainly referring to multi-line formatting here but I guess it makes sense for single line ss well.

karmeye avatar Feb 12 '23 06:02 karmeye

@karmeye , thanks for the request. I am not sure that what you are requesting is within scope of the sort keys rule. It is designed purely for single-level sorting because trying to sort anything nested can cause problems and may not be done correctly. If we were to use a library to do so, it may be possible, but then you may lose the exception list.

Is that the intended effects?

Also, what do you mean by it should also apply to lists? A key sort only affects keys and not values, so I think I am misunderstanding something.

pjkaufman avatar Feb 12 '23 10:02 pjkaufman

I was asking for nested sorting. How about setting a limit after three levels? That will cover most use cases.

If by "exceptions" you mean the "priority keys at start of yaml" setting, it's ok if only applies to the root level.

Right, lists/sequences are not keys. What I thought would be nice is to see the yaml tags and aliases sorted in alphabetical asc order.

karmeye avatar Feb 15 '23 12:02 karmeye

Sorry about the delay in responding.

I am not sure on a setting for the amount of levels to sort as that will cause a recursive pain in the logic. I would much rather pass this logic off to a library to handle, but thus far I have struck out on that front.

pjkaufman avatar May 17 '23 08:05 pjkaufman

Ok, whatever you feel is most appropriate. 👍

karmeye avatar May 30 '23 07:05 karmeye