Lodash orderBy case insensitive

Spread the love

Lodash orderBy case insensitive

//ascending

var data = [{
name: ‘ravi’,
age: 23
}, {
name: ‘Jon’,
age: 12
}, {
name: ‘kavi’,
age: 51
}, {
name: ‘Rose’,
age:33 } ];
const result = _.orderBy(data, [user => user.name.toLowerCase()], [‘asc’]);

console.log(‘result ‘, result);

 

//decending

var data = [{
name: ‘ravi’,
age: 23
}, {
name: ‘Jon’,
age: 12
}, {
name: ‘kavi’,
age: 51
}, {
name: ‘Rose’,
age:33 } ];
const result = _.orderBy(data, [user => user.name.toLowerCase()], [‘desc’]);

console.log(‘result ‘, result);

admin

admin

Leave a Reply

Your email address will not be published.