pregunta2 ordenamiento de equipos

This commit is contained in:
jls846
2025-11-27 18:16:06 -06:00
parent 6560ba5e36
commit 9bea8c9735
+4 -1
View File
@@ -31,13 +31,16 @@ interface RawOsEntry {
sistema_operativo: string;
total: string;
}
// Función profesional para transformar tu JSON a OsEntry[]
// Función profesional para transformar tu JSON a OsEntry[]
function transformPlatform(raw: RawOsEntry[]): OsEntry[] {
const rows: OsEntry[] = raw.map((item) => ({
os: item.sistema_operativo,
count: Number(item.total), // Convierte string a número
}));
rows.sort((a, b) =>
b.os.localeCompare(a.os, undefined, { numeric: true, sensitivity: "base" })
);
const total = rows.reduce((acc, r) => acc + r.count, 0);
rows.push({