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
255 stars 19 forks source link

How to sort the Chinese catalogue? #40

Closed zhoujiayaoo closed 1 year ago

zhoujiayaoo commented 1 year ago

How to set the Chinese directory at the bottom and English directory at the top?

zhoujiayaoo commented 1 year ago

I use the following configuration


sorting-spec: | target-folder: /* /folders

true a-z


But here's what happened image

I don't think that's reasonable,Thank you very much for your Chinese support.

SebastianMC commented 1 year ago

Hi @zhou-jiayao

I tried to reproduce an equivalent example locally. Take a look at the content of sortspec note below. I assume it is exactly the same on your computer, indentation matters - when you copied & pasted the example sortspec the indentation got lost. So the below sortspec content is my best-guess of the specification on your machine:

---
sorting-spec: |  
 target-folder: /*  
 /folders  
  > true a-z
---

with that sorting specification the order of File Explorer items in my test vault is:

2022-12-15_12-28-57

and for me it looks that the order of folders and files exactly matches the specification:

If you change the sorting order to (ascending) true alphabetical (change of > into > in the above example):

---
sorting-spec: |  
 target-folder: /*  
 /folders  
  < true a-z
---

you get the previous order of folders reversed:

2022-12-15_12-28-39

Does this clarification help?

And let me emphasise: Obsidian itself and the custom-sort plugin directly invoke platform sorting functions and fully rely on them (the so-called Collator). There is no internal custom code which examines the folder and notes titles to determine the order - it is delegated to the platform. I don't have much experience with Chinese and I have no idea what is the standard behavior of sorting. I believe that any system-wide customisation of locale and sorting will have influence on ordering of items in Obsidian.

If you want me to run your example on my machine, please:

[Edit] One additional question: maybe I misunderstood your request and the actual question is: can the custom sorting be based on language recognition so that you can configure 'Folder with Chinese characters go first'? If that's the question, the answer is that as of now the custom-sort plugin doesn't contain language-recognition-based capabilities. Only alphabetical (or reverse) ordering can be applied to folders and files names (which includes true alphabetical and the natural sorting orders, natural being equivalent to alphabetical in obsidian naming)

zhoujiayaoo commented 1 year ago

First of all, thank you very much for your reply. Your configuration here achieves exactly what I want. image

But I have the same configuration as you, and it shows the following result: image

That is, the file or directory with the Chinese title is always at the front, but I want it to be at the bottom, as you have implemented.

`

sorting-spec: |
target-folder: /*
/folders
< true a-z

` My configuration is exactly the same as yours, and the Chinese and English names are also regular, so I won't send you the complete configuration.

Looking forward to your reply again.

zhoujiayaoo commented 1 year ago

Sorry, I am not good at using github reply, the format configured above is wrong, I will send it again.

sorting-spec: |  
 target-folder: /*  
 /folders  
  < true a-z
SebastianMC commented 1 year ago

It looks that a kind of comment-based remote debugging session is needed :-) I suspect that your machine is configured in some way to produce the sorting order which you observe. Let's confirm that first. When I examine the vault folder from the system file explorer (which is finder app on macOS) I see the following behavior:

2022-12-18_19-56-17

the above image shows alphabetical sorting by name. The second image below shows reverse alphabetical sorting by name:

2022-12-18_19-56-43

as you can see, it is similar to what I observe at the Obsidian level on my side.

Could you please confirm, what you see in the system file explorer on your side? Also, when you turn off the custom-sort plugin in your vault, how the standard A-Z and Z-A sorting of Obsidian orders the folder and notes?

I'm trying to figure out if reaching the desired sorting order would require overriding of system/standard or not

SebastianMC commented 1 year ago

Hi @zhoujiayaoo

not having further input from you since Dec '22, I'm closing the ticket. Feel free to reopen it if we can proceed

thanks, Seb