I have an array of objects I'd like to order (essentially it's a table):
myArr = [{
name: 'John',
email: '[email protected]',
accepted: true
}, {
name: 'Alfred',
email: '[email protected]',
accepted: false
}]
I'm using orderBy from lodash like so:
//get columnName to sort by from another function
const newArr = _.orderBy(myArr, [columnName], ['asc'])
Ordering by name and email works fine, for accepted it doesn't do anything though. I understand I can store accepted as 0 and 1, but is there another way? Is lodash sufficient for that, or should I create a separate function for this?