Using Javascript with Underscore.js to Sort the other way

前端 未结 4 841
长情又很酷
长情又很酷 2021-02-01 14:01

I\'m using Javascript sort (with Underscore.js):

_.sortBy([\"Bob\", \"Mary\", \"Alice\"], function (name) {return name})
> [\"Alice\", \"Bob\", \         


        
4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 14:30

    Instead of throwing underscorejs away, I'd rather use it together with Array.reverse to utilize the best of both.

    _.sortBy(["Bob", "Mary", "Alice"], function (name) {return name})
     .reverse()
    

提交回复
热议问题