Looking to create an array in the format shown below:
[0: 0, 1: 1, 2: 2]
This is achieved using the following code snippet:
var arr = [];
for(i=0; i<3; i++){
arr[i] = i;
}
Upon execution, my array appears as follows:
[0, 1, 2]
The values within the array can be updated by their respective keys like so:
arr[0] = 2.5;
arr[1] = 8.4;
arr[2] = 3.7;
...
Ultimately, I intend to sort the array based on its values, resulting in a sequence similar to the one shown below:
[[0:2.5],[2:3.7],[1:8.4],...]