src/index.js
function sortCssDecls (cssDecls, sortOrder) {
  if (sortOrder === 'alphabetically') {
    timsort(cssDecls, (a, b) => {
      if (a.type === 'decl' && b.type === 'decl') {
        return comparator(a.prop, b.prop);
      } else {
        return compareDifferentType(a, b);
      }
    });
  } else {
    timsort(cssDecls, (a, b) => {
      if (a.type === 'decl' && b.type === 'decl') {
        const aIndex = sortOrder.indexOf(a.prop);
        const bIndex = sortOrder.indexOf(b.prop);
        return comparator(aIndex, bIndex);
      } else {
        return compareDifferentType(a, b);
      }
    });
  }
}
function sortCssDecls (cssDecls, sortOrder) {
  if (sortOrder === 'alphabetically') {
    timsort(cssDecls, (a, b) => {
      if (a.type === 'decl' && b.type === 'decl') {
        return comparator(a.prop, b.prop);
      } else {
        return compareDifferentType(a, b);
      }
    });
  } else {
    timsort(cssDecls, (a, b) => {
      if (a.type === 'decl' && b.type === 'decl') {
        const aIndex = sortOrder.indexOf(a.prop);
        const bIndex = sortOrder.indexOf(b.prop);
        return comparator(aIndex, bIndex);
      } else {
        return compareDifferentType(a, b);
      }
    });
  }
}
function sortCssDecls ( cssDecls , sortOrder ) { if ( sortOrder === 'alphabetically' ) { timsort ( cssDecls , ( a , b ) => { if ( a . type === 'decl' && b . type === 'decl' ) { return comparator ( a . prop , b . prop ) ; } else { return compareDifferentType ( a , b ) ; } } ) ; } else { timsort ( cssDecls , ( a , b ) => { if ( a . type === 'decl' && b . type === 'decl' ) { const aIndex = sortOrder . indexOf ( a . prop ) ; const bIndex = sortOrder . indexOf ( b . prop ) ; return comparator ( aIndex , bIndex ) ; } else { return compareDifferentType ( a , b ) ; } } ) ; } }
Sort CSS declarations alphabetically or using the set sorting order
Sort CSS declarations alphabetically or using the set sorting order