<!DOCTYPE html>
<html>
<body>
<h1>JavaScript 数组</h1>
<p>sort() 方法对数组的项目进行排序。</p>
<p id="demo"></p>
<script>
const points = [
{
"userId": 100,
"userName": "",
"nickName": "",
"mobilePhone": "admin",
"userPwd": "MTIz",
"userState": 200,
"userLogo": "",
"openId": "",
"regDateTime": "2023-09-28T17:02:01.07",
"regUserID": 0,
"regFullName": "",
"MerchantDataID": 1000
},
{
"userId": 20,
"userName": "",
"nickName": "",
"mobilePhone": "admin",
"userPwd": "MTIz",
"userState": 200,
"userLogo": "",
"openId": "",
"regDateTime": "2023-09-28T17:02:01.07",
"regUserID": 0,
"regFullName": "",
"MerchantDataID": 1000
},
{
"userId": 10,
"userName": "",
"nickName": "",
"mobilePhone": "admin",
"userPwd": "MTIz",
"userState": 200,
"userLogo": "",
"openId": "",
"regDateTime": "2023-09-28T17:02:01.07",
"regUserID": 0,
"regFullName": "",
"MerchantDataID": 1000
},
{
"userId": 300,
"userName": "",
"nickName": "",
"mobilePhone": "admin",
"userPwd": "MTIz",
"userState": 200,
"userLogo": "",
"openId": "",
"regDateTime": "2023-09-28T17:02:01.07",
"regUserID": 0,
"regFullName": "",
"MerchantDataID": 1000
},
{
"userId": 111123,
"userName": "",
"nickName": "",
"mobilePhone": "admin",
"userPwd": "MTIz",
"userState": 200,
"userLogo": "",
"openId": "",
"regDateTime": "2023-09-28T17:02:01.07",
"regUserID": 0,
"regFullName": "",
"MerchantDataID": 1000
},
{
"userId": 1,
"userName": "",
"nickName": "",
"mobilePhone": "admin",
"userPwd": "MTIz",
"userState": 200,
"userLogo": "",
"openId": "",
"regDateTime": "2023-09-28T17:02:01.07",
"regUserID": 0,
"regFullName": "",
"MerchantDataID": 1000
}
];
points.sort(function(a, b){return a.userId-b.userId});
document.getElementById("demo").innerHTML =JSON.stringify(points);
</script>
</body>
</html>