lensh / vue-qq

🎨 Vue family bucket with socket.io and express/koa2 , create a web version of mobile QQ, supporting real-time group chat, real-time private chat, special care, shielding chat, smart IP geographic location, real-time display temperature and other QQ core functions
MIT License
917 stars 230 forks source link

sort排序的问题 #20

Open lensh opened 6 years ago

lensh commented 6 years ago

按时间降序,之前写的是

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

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

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

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