Randomize line order
Aa TextRandomize the order of lines
$ echo "first
second
third
fourth
fifth" | shuffle-lines (input) => {
const lines = input.split("\n");
for (let i = lines.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[lines[i], lines[j]] = [lines[j], lines[i]];
}
return lines.join("\n");
}