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

sort排序的问题 #20

Open
lensh opened this issue Sep 1, 2017 · 0 comments
Open

sort排序的问题 #20

lensh opened this issue Sep 1, 2017 · 0 comments

Comments

@lensh
Copy link
Owner

lensh commented Sep 1, 2017

按时间降序,之前写的是

allMessage.sort((prev, current) => { //按时间降序排列
        return prev.time <  current.time
 })

这样写是错的,应该改成下面这样:

allMessage.sort((prev, current) => { //按时间降序排列
        return current.time - prev.time
 })

return的值必须要能包含大于0,小于0和等于0的情况。不能是true或false。

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

No branches or pull requests

1 participant