Change model sorting to natural order (#582)

Use natural sorting for model names.

Previously the model list was sorted lexicographically, which resulted
in unintuitive ordering when numbers were included in the name.

Example:

Before
qwen3.5:2B
qwen3.5:35B-3AB
qwen3.5:9B

After
qwen3.5:2B
qwen3.5:9B
qwen3.5:35B-3AB

This change sorts models using natural order so numeric parts are
compared numerically.
This commit is contained in:
tesuri
2026-03-12 23:49:34 +09:00
committed by GitHub
parent 24efdb76b1
commit d569681daa
+1 -1
View File
@@ -62,7 +62,7 @@ export function enableAPIEvents(enabled: boolean): void {
const newModels = JSON.parse(message.data) as Model[];
// Sort models by name and id
newModels.sort((a, b) => {
return (a.name + a.id).localeCompare(b.name + b.id);
return (a.name + a.id).localeCompare(b.name + b.id, undefined, { numeric : true} );
});
models.set(newModels);
break;