Created
January 2, 2019 20:43
-
-
Save taniarascia/cfaaef25b1462579f3fee80ad00c31c5 to your computer and use it in GitHub Desktop.
Compare object of arrays by property include nulls and secondary property
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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