当前位置:网站首页>Object. The disorder of key value array after keys
Object. The disorder of key value array after keys
2022-04-23 12:39:00 【AzeShinja】
About the cause of this problem
Why? Object.keys And so on keys Value will cause the problem of out of order output
My needs :
There are relevant units after the name of each test question ID, I do the sorting rule according to the intercepted string , This will make the unit 1 Normally displayed in the first position
If there are no relevant rules , Brothers can find their own way to build one , Or communicate well with the back-end , What is the order of display , Because after all, if you want to display in order, there must be relevant rules
One of the solutions to this problem I give is as follows :
The data type before my processing

There seems to be no problem here , But by Object.keys After output It's a unit 2 In the unit 1 In front of , So here we need to sort the processed data
const stringToArrSort = (target) => {
return Number(target.slice(target.lastIndexOf('-') + 1));
};
const sortArrByUnitId = (listData) => {
return listData.sort((a, b) => {
const sortA = stringToArrSort(a);
const sortB = stringToArrSort(b);
return sortA - sortB;
});
};
I'm through ‘-’ hold id out , Compare size , In this way, the output results can be displayed in normal order

版权声明
本文为[AzeShinja]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231238436161.html
边栏推荐
- STM32工程移植:不同型号芯片工程之间的移植:ZE到C8
- Message queuing overview
- Plato Farm-以柏拉图为目标的农场元宇宙游戏
- Source code analysis of synchronousqueue
- Intelligent multi line elastic cloud adds independent IP address. How to realize multi line function?
- [daily question] chessboard question
- 31岁才转行程序员,目前34了,我来说说我的经历和一些感受吧...
- Everything can be expected in the future | one 2022 campus recruitment officially opened
- STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
- How do programmers finalize nucleic acid statistics with 130 lines of code
猜你喜欢

免费试用一个月的服务器,并附上教程

Image attribute of input: type attribute of fashion cloud learning -h5

STM32工程移植:不同型号芯片工程之间的移植:ZE到C8

STM32 project transplantation: transplantation between chip projects of different models: Ze to C8

S2-062 remote command execution vulnerability recurrence (cve-2021-31805)

【Redis 系列】redis 学习十三,Redis 常问简单面试题

QT double buffer drawing

一个平面设计师的异想世界|ONES 人物

力扣刷题之完全二叉树的节点个数
![[csnote] ER diagram](/img/97/82e8c2183fcafda50950a953ca0955.png)
[csnote] ER diagram
随机推荐
How to prevent the website from being hacked and tampered with
BUUCTF WEB [BJDCTF2020]ZJCTF,不过如此
How do programmers finalize nucleic acid statistics with 130 lines of code
QT redraw events and cuts
PHP generates JSON to process Chinese
Unlock openharmony technology day! The annual event is about to open!
异步时钟亚稳态 的解决方案——多bit信号
基于卷积神经网络的遥感影像分类识别系统
Metalama简介4.使用Fabric操作项目或命名空间
Fashion cloud learning - input attribute summary
在 VSCode 中调试 Jest 的测试用例,VSCode调试Jest测试用例报错basedir=$(dirname “$(echo “$0“ | sed -e ‘s,\\,/,g‘)“)解决
BUUCTF WEB [BJDCTF2020]The mystery of ip
SQL exercise (I)
mysql中 innoDB执行过程分析
免费试用一个月的服务器,并附上教程
BUUCTF WEB [BJDCTF2020]The mystery of ip
Plato farm - a game of farm metauniverse with Plato as the goal
Luogu p3236 [hnoi2014] picture frame solution
Why is the premise of hash% length = = hash & (length-1) that length is the nth power of 2
STM32 project transplantation: transplantation between chip projects of different models: Ze to C8