当前位置:网站首页>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
边栏推荐
- 免费试用一个月的服务器,并附上教程
- leetcode:437. Path sum III [DFS selected or not selected?]
- [daily question] chessboard question
- BUUCTF WEB [BJDCTF2020]ZJCTF,不过如此
- 【Redis 系列】redis 学习十三,Redis 常问简单面试题
- The maximum number of remote desktop servers has been exceeded
- SynchronousQueue 源码解析
- 对话PostgreSQL作者Bruce:“转行”是为了更好地前行
- 【vulnhub靶场】-dc2
- uni-app 原生APP-云打包集成极光推送(JG-JPUSH)详细教程
猜你喜欢
随机推荐
One way ANOVA of SPSS
SynchronousQueue 源码解析
Web17——EL与JSTL的使用
Fashion cloud learning - input attribute summary
云原生KubeSphere部署Mysql
Can I take the CPDA data analyst certificate for 0 foundation
Uni app native app cloud packaging integrated Aurora push (jg-jpush) detailed tutorial
网络信息安全之零信任
Labels and paths
SPSS之单因素方差分析
Qt一个进程运行另一个进程
C, calculation code of parameter points of two-dimensional Bezier curve
Fastjson 2 来了,性能继续提升,还能再战十年
关于使用Go语言创建WebSocket服务浅谈
Solution of asynchronous clock metastability -- multi bit signal
C set Logo Icon and shortcut icon
QT draw text
NPDP | how can product managers not be excluded by programmers?
How to prevent the website from being hacked and tampered with
RT-thread中关键词解释及部分API