Skip to content

Instantly share code, notes, and snippets.

@taniarascia
Created January 2, 2019 20:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taniarascia/cfaaef25b1462579f3fee80ad00c31c5 to your computer and use it in GitHub Desktop.
Save taniarascia/cfaaef25b1462579f3fee80ad00c31c5 to your computer and use it in GitHub Desktop.
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