a zip code crypto-currency system good for red ONLY

tidy-rule-duplicates.js 397B

12345678910111213141516171819202122
  1. function ruleSorter(s1, s2) {
  2. return s1[1] > s2[1] ? 1 : -1;
  3. }
  4. function tidyRuleDuplicates(rules) {
  5. var list = [];
  6. var repeated = [];
  7. for (var i = 0, l = rules.length; i < l; i++) {
  8. var rule = rules[i];
  9. if (repeated.indexOf(rule[1]) == -1) {
  10. repeated.push(rule[1]);
  11. list.push(rule);
  12. }
  13. }
  14. return list.sort(ruleSorter);
  15. }
  16. module.exports = tidyRuleDuplicates;