Sorting and transforming text lines is a surprisingly common task. I built a browser-only tool covering 7 operations.
Try it: https://devnestio.pages.dev/line-sorter/
Sort modes
function sortLines(mode) {
let lines = prep(getLines('input-area'));
switch(mode) {
case 'asc': lines.sort((a, b) => ci(a).localeCompare(ci(b))); break;
case 'num-asc': lines.sort((a, b) => parseFloat(a) - parseFloat(b)); break;
case 'shuffle': // Fisher-Yates
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]];
}
break;
case 'reverse': lines.reverse(); break;
}
setOutput(lines);
}
Deduplicate
function dedup() {
const seen = new Set();
setOutput(lines.filter(l => {
const key = ci(l);
if (seen.has(key)) return false;
seen.add(key); return true;
}));
}
Features
- Sort A→Z, Z→A, 0→9, 9→0, by length, shuffle, reverse
- Deduplicate (case-sensitive or insensitive)
- Filter by regex (with invert option)
- Find & replace (literal or regex)
- Add prefix/suffix to each line
- Use as input to chain operations
- Live diff: shows +/− line count
DevNestio — browser-only developer tools.
Top comments (0)