Array with object sorting with Underscore sortBy

后端 未结 3 376
滥情空心
滥情空心 2020-12-24 04:49

I have this array. How do I use underscore \'_.sortBy\' to sort it according to start date?

[
    { 
        id: \'oljw832021kjnb389xzll323jk\',
        star         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-24 05:02

    Use an iterator function, not a single string for a property:

    _.sortBy(arr, function(o) { return o.start.dateTime; })
    

提交回复
热议问题