导航

萌即是正义!时不时分享一些ACG活动记录与有趣代码的小站!

侧边栏
最新评论
广树管理员
2025-11-17 10:58
@HelloGakki:期待大佬的结果
LuckyA
2025-11-17 10:41
ヾ(≧∇≦*)ゝ
HelloGakki
2025-11-17 09:47
@广树:我直接让chatgpt给我生成提示词了哈哈,效果还不错
广树管理员
2025-11-17 09:26
@HelloGakki:有点看运气,描述的时候强调 强烈的手办质感 。最好加入照片背景布局的描述效果更好。
HelloGakki
2025-11-17 09:23
@广树:我去试试!
攻略中
全民高尔夫环球之旅
暂无评分
Steam全民高尔夫环球之旅
2025年9月07日 12时 ~ 攻略中
已累计游玩2个月11天
《全民高尔夫 环球之旅》除了能体验到与过去作品相同的乐趣、爽快与深奥之外, 还有着以精美图像设计而成、个性丰富的角色们与以世界各地为主题的球场, 以及能让所有人热血沸腾的全新模式等等,是本系列的全新力作!
ToHeart
暂无评分
SteamToHeart
2025年6月26日 19时 ~ 攻略中
已累计游玩4个月24天
AQUAPLUS推出的“温暖人心的校园恋爱游戏”将以高清全3D形式焕新归来!
fault - StP - LIGHTKRAVTE
暂无评分
Steamfault - StP - LIGHTKRAVTE
2025年5月29日 20时 ~ 攻略中
已累计游玩5个月21天
全球累计销量超过50万份的“fault”系列最新作!故事的舞台是一个融合了奇幻与科幻的超前世界——卢森海德王国。本作讲述了生活在此地的一个平凡又平庸的究极普通市民——名为果子的少年的故事。
PSN奖杯卡

PSN奖杯卡

归档
赞助商广告

JS根据列表排列对象数组

作者:广树时间:2019-05-08 09:39:51分类:JavaScript

应用场景:将对象数组根据指派的数组内容进行排序,未指定的对象按照原始顺序。

const nodeData_ = [
    {account:'a',node:1},
    {account:'b',node:2},
    {account:'c',node:3},
    {account:'d',node:4},
    {account:'e',node:5},
    {account:'f',node:6}
]
const sortInfo = ['f','c','b']
nodeData_.sort((a, b) => {
    if (sortInfo.indexOf(a.account) === -1 && sortInfo.indexOf(b.account) === -1) {
        return 1
    } else if (sortInfo.indexOf(a.account) !== -1 && sortInfo.indexOf(b.account) === -1) {
        return -1
    } else if (sortInfo.indexOf(a.account) === -1 && sortInfo.indexOf(b.account) !== -1) {
        return 1
    }
    return sortInfo.indexOf(a.account) - sortInfo.indexOf(b.account)
})
console.log(nodeData_)

输出结果:

0: {account: "f", node: 6}
1: {account: "c", node: 3}
2: {account: "b", node: 2}
3: {account: "a", node: 1}
4: {account: "d", node: 4}
5: {account: "e", node: 5}

donate.png


telegram banner (1).png


1210 x 50(蓝底).png

cloudcone