mirror of
https://github.com/gchq/CyberChef
synced 2025-01-01 07:18:47 +00:00
Merge branch 'master' of https://github.com/DidierStevens/CyberChef
This commit is contained in:
commit
23403f55a5
2 changed files with 16 additions and 2 deletions
|
@ -103,3 +103,15 @@ export function hexadecimalSort(a, b) {
|
||||||
|
|
||||||
return a.localeCompare(b);
|
return a.localeCompare(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comparison operation for sorting of lines by length
|
||||||
|
*
|
||||||
|
* @param {string} a
|
||||||
|
* @param {string} b
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
export function lengthSort(a, b) {
|
||||||
|
return a.length - b.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import Utils from "../Utils.mjs";
|
import Utils from "../Utils.mjs";
|
||||||
import {INPUT_DELIM_OPTIONS} from "../lib/Delim.mjs";
|
import {INPUT_DELIM_OPTIONS} from "../lib/Delim.mjs";
|
||||||
import {caseInsensitiveSort, ipSort, numericSort, hexadecimalSort} from "../lib/Sort.mjs";
|
import {caseInsensitiveSort, ipSort, numericSort, hexadecimalSort, lengthSort} from "../lib/Sort.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort operation
|
* Sort operation
|
||||||
|
@ -39,7 +39,7 @@ class Sort extends Operation {
|
||||||
{
|
{
|
||||||
"name": "Order",
|
"name": "Order",
|
||||||
"type": "option",
|
"type": "option",
|
||||||
"value": ["Alphabetical (case sensitive)", "Alphabetical (case insensitive)", "IP address", "Numeric", "Numeric (hexadecimal)"]
|
"value": ["Alphabetical (case sensitive)", "Alphabetical (case insensitive)", "IP address", "Numeric", "Numeric (hexadecimal)", "Length"]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,8 @@ class Sort extends Operation {
|
||||||
sorted = sorted.sort(numericSort);
|
sorted = sorted.sort(numericSort);
|
||||||
} else if (order === "Numeric (hexadecimal)") {
|
} else if (order === "Numeric (hexadecimal)") {
|
||||||
sorted = sorted.sort(hexadecimalSort);
|
sorted = sorted.sort(hexadecimalSort);
|
||||||
|
} else if (order === "Length") {
|
||||||
|
sorted = sorted.sort(lengthSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sortReverse) sorted.reverse();
|
if (sortReverse) sorted.reverse();
|
||||||
|
|
Loading…
Reference in a new issue