I am using the following bookmarklet to sort textarea ascending or descending. It is working as expected. But I do not need descending sort option and there is no need of arrows like '↑' or '↓'
I am not able to extract the basic sort function from this code.
javascript: (
function() {
Array.from(document.querySelectorAll('textarea')).map(function(b) {
var a = document.createElement('div');
var d = document.createElement('button');
d.textContent = '↑';
d.addEventListener('click', function(f) {
f.preventDefault();
b.value = Array.from(new Set(b.value.split('\n'))).sort().join('\n')
});
var c = document.createElement('button');
c.textContent = '↓';
c.addEventListener('click', function(f) {
f.preventDefault();
b.value = Array.from(new Set(b.value.split('\n'))).sort().reverse().join('\n')
});
a.appendChild(d);
a.appendChild(c);
b.parentNode.insertBefore(a, b)
})
}
)();
Any help will be appreciated.