I created a dictionary (it's just an object) in typescript using an existing array. The keys got sorted automatically. When I use an array of strings instead of numbers the sorting doesn't work. I suppose must be something related to index when using numbers as keys.
let dict: {[key: string]: number} = {};
const arr = [123, 333, 10, 4];
for (let el of arr) {
dict[el] = 1;
}
console.log(dict);