Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
OlehDutchenko committed Sep 7, 2024
2 parents a7d6e1a + d7acfc0 commit 0a056bc
Show file tree
Hide file tree
Showing 3 changed files with 5,033 additions and 13 deletions.
41 changes: 41 additions & 0 deletions lib/create-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const maxHeight = /\(\s*max(-device)?-height|\(\s*height\s*<(=)?/i;
const isMinHeight = _testQuery(minMaxHeight, maxMinHeight, minHeight);
const isMaxHeight = _testQuery(maxMinHeight, minMaxHeight, maxHeight);

const lessThan = /<(?!=)/;
const grtrThan = />(?!=)/;

const isPrint = /print/i;
const isPrintOnly = /^print$/i;

Expand Down Expand Up @@ -202,6 +205,25 @@ module.exports = function createSort(configuration) {
return -1;
}

if (lengthA === lengthB) {
if (maxA && maxB) {
if (lessThan.test(a) && !lessThan.test(b)) {
return 1;
}
if (!lessThan.test(a) && lessThan.test(b)) {
return -1;
}
}
if (minA && minB) {
if (grtrThan.test(a) && !grtrThan.test(b)) {
return 1;
}
if (!grtrThan.test(a) && grtrThan.test(b)) {
return -1;
}
}
}

return a.localeCompare(b);
}
}
Expand Down Expand Up @@ -263,6 +285,25 @@ module.exports = function createSort(configuration) {
return -1;
}

if (lengthA === lengthB) {
if (maxA && maxB) {
if (lessThan.test(a) && !lessThan.test(b)) {
return 1;
}
if (!lessThan.test(a) && lessThan.test(b)) {
return -1;
}
}
if (minA && minB) {
if (grtrThan.test(a) && !grtrThan.test(b)) {
return 1;
}
if (!grtrThan.test(a) && grtrThan.test(b)) {
return -1;
}
}
}

return -a.localeCompare(b);
}
};
Expand Down
Loading

0 comments on commit 0a056bc

Please sign in to comment.