Skip to content

Instantly share code, notes, and snippets.

@matheusdavidson
Last active July 9, 2017 19:09
Show Gist options
  • Save matheusdavidson/599780bcd2d579639c8da2016ee12e0c to your computer and use it in GitHub Desktop.
Save matheusdavidson/599780bcd2d579639c8da2016ee12e0c to your computer and use it in GitHub Desktop.
let _ = require('lodash');
let games = [{
name: 'Street Fighter',
year: 1990
},
{
name: 'Mortal Kombat',
year: 1991
},
{
name: 'Top Gear',
year: 1992
}
]
//
// Crescente
let result = _.sortBy(games, ['name']);
//
// Decrescente
// let result = _.sortBy(games, ['name']).reverse();
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment