index.js
function(a, b, isMax) {
      var sortValA = a.sortVal,
              sortValB = b.sortVal;
      isMax = typeof isMax !== 'undefined' ? isMax : false;

      // consider print for sorting if sortVals are equal
      if (sortValA === sortValB) {
        if (a.rule.match(/print/)) {
          // a contains print and should be sorted after b
          return 1;
        }
        if (b.rule.match(/print/)) {
          // b contains print and should be sorted after a
          return -1;
        }
      }

      // return descending sort order for max-(width|height) media queries
      if (isMax) {
        return sortValB - sortValA;
      }

      // return ascending sort order
      return sortValA - sortValB;
    }
function(a, b, isMax) {
      var sortValA = a.sortVal,
              sortValB = b.sortVal;
      isMax = typeof isMax !== 'undefined' ? isMax : false;

      // consider print for sorting if sortVals are equal
      if (sortValA === sortValB) {
        if (a.rule.match(/print/)) {
          // a contains print and should be sorted after b
          return 1;
        }
        if (b.rule.match(/print/)) {
          // b contains print and should be sorted after a
          return -1;
        }
      }

      // return descending sort order for max-(width|height) media queries
      if (isMax) {
        return sortValB - sortValA;
      }

      // return ascending sort order
      return sortValA - sortValB;
    }
function ( a , b , isMax ) { var sortValA = a . sortVal , sortValB = b . sortVal ; isMax = typeof isMax !== 'undefined' ? isMax : false ; // consider print for sorting if sortVals are equal if ( sortValA === sortValB ) { if ( a . rule . match ( / print / ) ) { // a contains print and should be sorted after b return 1 ; } if ( b . rule . match ( / print / ) ) { // b contains print and should be sorted after a return - 1 ; } } // return descending sort order for max-(width|height) media queries if ( isMax ) { return sortValB - sortValA ; } // return ascending sort order return sortValA - sortValB ; }
Function to determine sort order
Function to determine sort order