当前位置:网站首页>Array sorts in the specified order
Array sorts in the specified order
2022-06-12 17:40:00 【Deshun】
Array sorting can be used directly sort() Method , You can sort arrays regularly .
But if you specify an irregular order for sorting ?
It can also be used sort() Method :
const data = [
{ name: ' Zhang San ', code: 'zs' },
{ name: ' Wang Wu ', code: 'ww' },
{ name: ' Zhao Qi ', code: 'zq' },
];
data.sort((star, next) => {
const sortList = ['zq', 'zs', 'ww']
return sortList.indexOf(star.code) - sortList.indexOf(next.code);
});That's it .
No reprint without permission :w3h5 » Array sorts in the specified order
边栏推荐
- ssm常用到的依赖
- R语言使用ggplot2可视化dataframe数据中特定数据列的密度图(曲线)、并使用xlim参数指定X轴的范围
- C#操作数据库增查业务数据值内容案例学校表
- 分辨率与行场同步信号的关系 场消隐
- Tidb Hackathon 2021 - pcloud: conduct icloud pcloud team interview on the database
- The significance of writing technology blog
- 龙芯处理器内核中断讲解
- 内核中断整体流程图
- C# 业务流水号规则生成组件
- TensorFlow求梯度时提示TypeError: unsupported operand type(s) for *: ‘float‘ and ‘NoneType‘
猜你喜欢

Installation and use of rolabelimg

Volcano engine held a video cloud technology force summit and released a new experience oriented video cloud product matrix

Arm64 stack backtracking

文章名字

Learn the mitmproxy packet capturing tool from scratch

Notes on user experience elements: user centered product design

Risc-v ide mounriver studio v1.60 update point introduction

Hangzhou AI developer meetup registration opens!

I heard that distributed IDS cannot be incremented globally?
![Vulnhub[DC3]](/img/3a/1aa03e804d447d38e85807928fdb8f.png)
Vulnhub[DC3]
随机推荐
Sizepolicy policy in layout management
Cesium parabolic equation
认识函数原创
消息队列存储消息数据的 MySQL 表格
龙芯处理器内核中断讲解
(7) Loop statement for
Qiushengchang: Practice of oppo commercial data system construction
字节飞书人力资源套件三面
R语言使用epiDisplay包的aggregate.plot函数可视化每个子集的汇总统计信息(可视化基于单个分组下的阳性指标的概率值及其95%置信区间、基于折线图、仅仅适用于目标类别为二分类)
Gerrit triggers Jenkins sonarqube scan
分辨率与行场同步信号的关系 场消隐
Alibaba cloud image station supports IPv6!
WinForm, crystal report making
Yyds dry goods inventory leetcode question set 911 - 920
消息队列实战之队列优先级
布局管理中的sizePolicy的策略问题
使用MongoDB官方go库操作MongoDB原创
Detailed explanation of shardingjdbc database and table
Goframe gredis configuration management | comparison of configuration files and configuration methods
SqlServer常用语句及函数