const Moment = require('moment')
const array = [{date:"2018-05-11"},{date:"2018-05-12"},{date:"2018-05-10"}]
const sortedArray = array.sort((a,b) => new Moment(a.date).format('YYYYMMDD') - new Moment(b.date).format('YYYYMMDD'))
console.log(sortedArray)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const persons = [ | |
{ 'name':'Luke', 'age':10}, | |
{ 'name':'Leia', 'age':10}, | |
{ 'name':'Vader', 'age':40} | |
]; | |
const ascending = x => y => x > y; | |
const ageSort = (x, y) => ascending(x.age)(y.age); |
'use strict';
const callMock = (object) => new Promise((resolve) => setTimeout(() => resolve(object), 500));
const print = (method, petOne, petTwo) => {
console.log(`Method: ${method}`);
console.log(`PetOne: ${JSON.stringify(petOne)}`);
console.log(`PetTwo: ${JSON.stringify(petTwo)}`);
};