🔤 Text Sorter

Sort text lines A-Z, Z-A, or by length. Free online sorter.

Share: 🐦 Twitter 📘 Facebook

Similar Tools

About This Tool

Sort text lines A-Z, Z-A, or by length. Free online sorter.

How to Use

Tool Network

ToolfastproSkillgohubSmarttoolgoBesttoolfun
function initTool() { document.getElementById('tool-app').innerHTML = '
';
}
function doIt() {
  var lines = document.getElementById('inp').value.split(String.fromCharCode(10));
  var o = document.getElementById('order').value;
  if (o === 'asc') lines.sort(function(a,b){return a.localeCompare(b);});
  else if (o === 'desc') lines.sort(function(a,b){return b.localeCompare(a);});
  else if (o === 'len') lines.sort(function(a,b){return a.length-b.length;});
  else lines.sort(function(a,b){return b.length-a.length;});
  document.getElementById('out').textContent = lines.join(String.fromCharCode(10));
}
function clearAll() { document.getElementById('inp').value = ''; document.getElementById('out').textContent = ''; }
window.addEventListener('DOMContentLoaded', initTool);

n