当前位置:网站首页>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
边栏推荐
- 一个平面设计师的异想世界|ONES 人物
- Metalama简介4.使用Fabric操作项目或命名空间
- Realize several "Postures" in which a box is horizontally and vertically centered in the parent box
- leetcode:437. Path sum III [DFS selected or not selected?]
- Web17 -- use of El and JSTL
- QT redraw events and cuts
- 云原生KubeSphere部署Redis
- 【微信小程序】z-index失效
- Analysis of InnoDB execution process in MySQL
- Zero trust in network information security
猜你喜欢
传统企业如何应对数字化转型?这些书给你答案
云原生KubeSphere部署Redis
Number of nodes of complete binary tree
【每日一题】棋盘问题
Zigbee之CC2530最小系统及寄存器配置(1)
没有空闲服务器?导入 OVF 镜像快速体验 SmartX 超融合社区版
[unity note] basic lighting in l4unity
STM32 project transplantation: transplantation between chip projects of different models: Ze to C8
电脑系统卡如何解决?
对话PostgreSQL作者Bruce:“转行”是为了更好地前行
随机推荐
对话PostgreSQL作者Bruce:“转行”是为了更好地前行
Qt双缓冲绘图
Source code analysis of synchronousqueue
Worder font page font comparison table
BaseRecyclerViewAdapterHelper 实现下拉刷新和上拉加载
CGC: contractual graph clustering for community detection and tracking
MySQL函数-递归函数
大家帮我看一下这是啥情况,MySQL5.5的。谢了
Ad20 supplementary note 3 - shortcut key + continuous update
Luogu p5540 [balkanoi2011] timeismoney | minimum product spanning tree problem solution
基于卷积神经网络的遥感影像分类识别系统
Unlock openharmony technology day! The annual event is about to open!
Xinwangda announced that the price of battery products had been increased, and the investment of "weixiaoli" exceeded 1 billion
一个平面设计师的异想世界|ONES 人物
[daily question] chessboard question
C, calculation code of parameter points of two-dimensional Bezier curve
Uni app native app cloud packaging integrated Aurora push (jg-jpush) detailed tutorial
Markdown语法学习
Qt绘制图像
实现一个盒子在父盒子中水平垂直居中的几种“姿势”