Last active
March 13, 2020 16:32
-
-
Save buddhamagnet/c7d3328071bdfc94f3b338df4b49e288 to your computer and use it in GitHub Desktop.
sort.js
This file contains hidden or 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
const mappedConversionRulesets = [ | |
{ ScoringEngine: 100, LineOfBusiness: 100 }, | |
{ ScoringEngine: 10, LineOfBusiness: 10 }, | |
{ ScoringEngine: 5, LineOfBusiness: 100 }, | |
{ ScoringEngine: 5, LineOfBusiness: 5000 }, | |
{ ScoringEngine: 5, LineOfBusiness: 100 }, | |
{ ScoringEngine: 1000, LineOfBusiness: 100 } | |
]; | |
const sortScoreConversionClever = mappedConversionRulesets.sort((a, b) => | |
a.ScoringEngine > b.ScoringEngine | |
? 1 | |
: a.ScoringEngine === b.ScoringEngine | |
? a.LineOfBusiness > b.LineOfBusiness | |
? 1 | |
: -1 | |
: -1 | |
); | |
const sortScoreConversionClear = mappedConversionRulesets.sort((a, b) => { | |
if (a.ScoringEngine > b.ScoringEngine) { | |
if (a.ScoringEngine === b.ScoringEngine) { | |
if (a.LineOfBusiness < b.LineOfBusiness) { | |
return 1; | |
} else { | |
return -1; | |
} | |
} | |
} else { | |
return -1; | |
} | |
}); | |
console.log(sortScoreConversionClever); | |
console.log(sortScoreConversionClear); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment