Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

按标题升序规则bug!!! #935

Open
fanlushuai opened this issue Feb 23, 2020 · 3 comments
Open

按标题升序规则bug!!! #935

fanlushuai opened this issue Feb 23, 2020 · 3 comments

Comments

@fanlushuai
Copy link

@fanlushuai fanlushuai commented Feb 23, 2020

image

10 11竟然在1的后面。

这个明显是取收个字母升序的。低级问题。

当切换成中文的,一、二、三、四的时候,竟然还是乱序的。

那么问题来了。

这个升序规则能不能解释一下,目前我看到的是这个代码写的好脆弱,不堪一击。

@hyfree

This comment has been minimized.

Copy link

@hyfree hyfree commented Feb 29, 2020

Note.sortNotes = function (notes) {

目前,leanote的网页端排序规则是使用sort方法,实际上它使用字符串的ASCII码进行排序,在sort比较函数中,字符串的比较简单地用 “> < ==”进行比较然后排序,所以会出现这种意料之外的排序结果。
参考:
Array.prototype.sort()
String.prototype.localeCompare()

@fanlushuai

This comment has been minimized.

Copy link
Author

@fanlushuai fanlushuai commented Feb 29, 2020

Note.sortNotes = function (notes) {

目前,leanote的网页端排序规则是使用sort方法,实际上它使用字符串的ASCII码进行排序,在sort比较函数中,字符串的比较简单地用 “> < ==”进行比较然后排序,所以会出现这种意料之外的排序结果。
参考:
Array.prototype.sort()
[String.prototype.localeCompare()](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare

意料之外,那么是不是需要处理一下?希望完善一下。

@hyfree

This comment has been minimized.

Copy link

@hyfree hyfree commented Feb 29, 2020

😳等leanote官方修复吧,按照目前的维护速度,估计得等到明年

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.