How to sort an array of timestamps using lodash in desc order

前端 未结 7 1215
情话喂你
情话喂你 2021-01-12 22:46

I want to sort the following array of timestamps using lodash so the latest time stamp is first [3].

Code:

let timestamps = [\"2017-         


        
7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 23:33

    orderBy allows you to specify the sort orders while sortBy does not.

    const sorted = orderBy(timestamps, ['desc']);
    

提交回复
热议问题