Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Js sorts the Json array

Shulou Source: shulou.com Published: 2022-06-01 08:09:50 09月22日 Update

Due to the need for conversion of various data types to process data with java, it is very depressing, and individuals prefer to use js for data processing. I hope it will be helpful to you to go to code directly:

Function sortJsonArr (jsonArr, sortName, sortType) {if (sortName & & sortType & & jsonArr! = null & & jsonArr.length > 0) {sortType = sortType.toUpperCase (); var direction = 1; if (sortType = 'DESC') {direction =-1 } jsonArr.sort (function (obj1, obj2) {if (obj1 [sortName] > obj2 [sortName]) {return 1 * direction;} else {return-1 * direction;}}) }}

Tags: Data processing depression personal data processing type help array sorting Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Redmi MariaDB NVidia Shulou Technology