[Javascript] Array sort - keep one item always last
For example, we have a dropdown list, we want to keep "other" option always as last option.
return options .sort((a, b) => { if (a.value == b.value) return 0; if (a.value == 'other') return 1; if (b.value == 'other') return -1; return a.value.localeCompare(b.value); });
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
2020-02-07 [Algorithm] 189. Rotate Array
2020-02-07 [Angular] Preparing an Angular Application for Continuous Integration (CI)
2019-02-07 [Functional Programming ADT] Combine Multiple State ADT Based Redux Reducers
2019-02-07 [Angular] Introduction to Angular Internationalization (i18n)
2019-02-07 [Javascript] Wrap an API with a Proxy
2019-02-07 [React] Detect user activity with a custom useIdle React Hook
2019-02-07 [Javascript] Automate the process of flattening deeply nested arrays using ES2019's flat method