Get the App
SLTechnology News&Howtos  ›  Development  › 

How to sort alphabetically in JavaScript

Shulou Source: shulou.com Published: 2022-06-01 02:56:27 09月22日 Update

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!

Tags: Sorting articles letters values interests at the same time arrays more friends knowledge editing industry information information channels order channels references learning help support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Technology macOS MariaDB NVidia