refac
This commit is contained in:
+17
-1
@@ -27,7 +27,23 @@ export const getModels = async (token: string = '') => {
|
||||
|
||||
let models = res?.data ?? [];
|
||||
|
||||
models = models.filter((models) => models).sort((a, b) => (a.name > b.name ? 1 : -1));
|
||||
models = models
|
||||
.filter((models) => models)
|
||||
.sort((a, b) => {
|
||||
// Compare case-insensitively
|
||||
const lowerA = a.name.toLowerCase();
|
||||
const lowerB = b.name.toLowerCase();
|
||||
|
||||
if (lowerA < lowerB) return -1;
|
||||
if (lowerA > lowerB) return 1;
|
||||
|
||||
// If same case-insensitively, sort by original strings,
|
||||
// lowercase will come before uppercase due to ASCII values
|
||||
if (a < b) return -1;
|
||||
if (a > b) return 1;
|
||||
|
||||
return 0; // They are equal
|
||||
});
|
||||
|
||||
console.log(models);
|
||||
return models;
|
||||
|
||||
Reference in New Issue
Block a user