JSFiddle - React, Tailwind, and code Playground

by Rodrigo Portillo

JavaScript

let index = 1;

var data = [
    [105,  "FIAT"],
    [5,  "BONNIE"],
    [57,  "ALPHA ROMEO"],
    [109,  "CARLA"],
];
data.sort(function (a, b) {
   if (a[index] === b[index]) {
        return index;
    }
    else {
        return (a[index] < b[index]) ? -1 : 1;
    }
});

//ao contrário
//data.reverse();

console.log(data);