当前位置:网站首页>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
边栏推荐
- 使用Source Insight查看编辑源代码
- mysql中 innoDB执行过程分析
- Stm32cubeprogrammer basic instructions
- Fastjson 2 is coming, the performance continues to improve, and it can fight for another ten years
- Intelligent multi line elastic cloud adds independent IP address. How to realize multi line function?
- 风尚云网学习-h5的input:type属性的image属性
- Pagoda panel command line help tutorial (including resetting password)
- Basic software testing Day2 - Case Execution
- uni-app 原生APP-云打包集成极光推送(JG-JPUSH)详细教程
- 在 VSCode 中调试 Jest 的测试用例,VSCode调试Jest测试用例报错basedir=$(dirname “$(echo “$0“ | sed -e ‘s,\\,/,g‘)“)解决
猜你喜欢
31岁才转行程序员,目前34了,我来说说我的经历和一些感受吧...
云原生KubeSphere部署Mysql
box-sizing
Idea setting copyright information
STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
One way ANOVA of SPSS
Bert base Chinese Download (SMART)
Fastjson 2 来了,性能继续提升,还能再战十年
Number of nodes of complete binary tree
AI video cloud vs narrowband HD, who is the darling of the video era
随机推荐
SynchronousQueue 源码解析
解决disagrees about version of symbol device_create
Why is the premise of hash% length = = hash & (length-1) that length is the nth power of 2
Image attribute of input: type attribute of fashion cloud learning -h5
uni-app 原生APP-本地打包集成极光推送(JG-JPUSH)详细教程
How do traditional enterprises cope with digital transformation? These books give you the answer
风尚云网学习-input属性总结
实现一个盒子在父盒子中水平垂直居中的几种“姿势”
Qt重绘事件与剪切
Qt一个进程运行另一个进程
Bert base Chinese Download (SMART)
Pre competition practice of TIANTI competition
bert-base-chinese下载(智取)
Qt双缓冲绘图
网站首页文件被攻击篡改的形式有哪些
BUUCTF WEB [BUUCTF 2018]Online Tool
Unlock openharmony technology day! The annual event is about to open!
Dialogue with Bruce, author of PostgreSQL: "changing careers" is to better move forward
Qt绘制文字
没有空闲服务器?导入 OVF 镜像快速体验 SmartX 超融合社区版