From b4b6e3d4d8c164d98764eac40907b6f92f5b0d97 Mon Sep 17 00:00:00 2001 From: cenfun Date: Sat, 22 Jun 2024 09:01:36 +0800 Subject: [PATCH] sort type and base --- js/model-manager.js | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/js/model-manager.js b/js/model-manager.js index 95668e7d..d6efd386 100644 --- a/js/model-manager.js +++ b/js/model-manager.js @@ -555,27 +555,46 @@ export class ModelManager { }); - this.typeList = [{ - label: "All", - value: "" - }]; + const typeList = []; typeMap.forEach(type => { - this.typeList.push({ + typeList.push({ label: type, value: type }); }); - - this.baseList = [{ + typeList.sort((a,b)=> { + const au = a.label.toUpperCase(); + const bu = b.label.toUpperCase(); + if (au !== bu) { + return au > bu ? 1 : -1; + } + return 0; + }); + this.typeList = [{ label: "All", value: "" - }]; + }].concat(typeList); + + + const baseList = []; baseMap.forEach(base => { - this.baseList.push({ + baseList.push({ label: base, value: base }); }); + baseList.sort((a,b)=> { + const au = a.label.toUpperCase(); + const bu = b.label.toUpperCase(); + if (au !== bu) { + return au > bu ? 1 : -1; + } + return 0; + }); + this.baseList = [{ + label: "All", + value: "" + }].concat(baseList); return models; }