JSFiddle - React, Tailwind, and code Playground
Sort question keys.
by Nalin Sajwan
JavaScript
var keysArr = [
"1.1.1",
"1.1",
"2.2.3",
"2.1",
"3.3.1",
"3",
"4",
"1"
];
console.log("keysArr ==> ", keysArr);
var keysSorted = [...keysArr].sort(function(a, b) {
var tA = typeof a, tB = typeof b;
return tA<tB ? -1 : tA>tB ? 1 : a < b ? -1 : a > b ? 1 : 0;
});
console.log("keysSorted ==> ", keysSorted);