♻️ Improve sorting

This commit is contained in:
Daniel 2024-09-14 22:07:09 +08:00
parent b6af01ecd3
commit 89f46b8148
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
6 changed files with 38 additions and 33 deletions

View file

@ -21,11 +21,21 @@ import (
"io"
"strings"
"github.com/facette/natsort"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/transform"
)
func NaturalCompare(str1, str2 string) bool {
str1 = RemoveEmojiInvisible(str1)
str2 = RemoveEmojiInvisible(str2)
return natsort.Compare(str1, str2)
}
func PinYinCompare(str1, str2 string) bool {
str1 = RemoveEmojiInvisible(str1)
str2 = RemoveEmojiInvisible(str2)
// Doc tree, backlinks, tags and templates ignores case when sorting alphabetically by name https://github.com/siyuan-note/siyuan/issues/8360
str1 = strings.ToLower(str1)
str2 = strings.ToLower(str2)