Last active
December 4, 2015 10:28
-
-
Save dejanr/f122e554139c1405c634 to your computer and use it in GitHub Desktop.
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 combine = (...comparators) => (x, y) => comparators.reduce((prev, next) => prev || next(x, y), 0); | |
| const comparators = { | |
| topCalculatedTariff: (x, y) => topCalculatedTariffService.isTopCalculatedTariff(y) - topCalculatedTariffService.isTopCalculatedTariff(x), | |
| premiumAsc: (x, y) => x.monthlyPremiumGrossInEur - y.monthlyPremiumGrossInEur, | |
| premiumDesc: (x, y) => y.monthlyPremiumGrossInEur - x.monthlyPremiumGrossInEur, | |
| gradeAsc: (x, y) => x.grade - y.grade, | |
| gradeDesc: (x, y) => y.grade - x.grade | |
| }; | |
| const sortByOptions = [ | |
| { label: 'günstigster Preis', value: 'premium-ascending', comparator: combine(comparators.topCalculatedTariff, comparators.premiumAsc, comparators.gradeAsc) }, | |
| { label: 'teuerster Preis', value: 'premium-descending', comparator: combine(comparators.topCalculatedTariff, comparators.premiumDesc, comparators.gradeAsc) }, | |
| { label: 'beste Note', value: 'grade-ascending', comparator: combine(comparators.topCalculatedTariff, comparators.gradeAsc, comparators.premiumAsc) }, | |
| { label: 'schlechteste Note', value: 'grade-descending', comparator: combine(comparators.topCalculatedTariff, comparators.gradeDesc, comparators.premiumAsc) } | |
| ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment