Skip to content

Instantly share code, notes, and snippets.

@taniarascia taniarascia/sort.js
Created Jan 2, 2019

Embed
What would you like to do?
Compare object of arrays by property include nulls and secondary property
function compareProperty(a, b) {
return a || b ? (!a ? 1 : !b ? -1 : a.localeCompare(b)) : 0
}
function myComparer(a, b) {
return compareProperty(a.jewelerName, b.jewelerName) || compareProperty(a.name, b.name)
}
// Flatten array
const flattened = [].concat.apply([], tableAssignmentsLookup)
const csvRows = flattened.sort(myComparer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.