Sort array of objects with date field by date

后端 未结 5 796
猫巷女王i
猫巷女王i 2021-01-31 03:10

Give the following array of objects, I need to sort them by the date field ascending.

var myArray = [
  {
    name: \"Joe Blow\",
    date: \"Mon Oct 31 2016 00:         


        
5条回答
  •  难免孤独
    2021-01-31 03:31

    just write _.sortBy({yourCollection}, {the field name});

    lodash will automatically figure that this is a date and it'll work like a magic!

    Awesome!

提交回复
热议问题