How to sort alphabetically in JavaScript
This article mainly introduces how JavaScript can be sorted alphabetically. It has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
function setSort() {
var text = K1.value
.split(/[\r\n]/)
.sort()
.join("\r\n"); //order
var test = K1.value
.split(/[\r\n]/)
.sort()
.reverse()
.join("\r\n"); //reverse order
K1.value = K1.value != text ? text : test;
} Thank you for reading this article carefully. I hope that the article "How to Sort JavaScript Alphabetically" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support it a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!