JSFiddle - React, Tailwind, and code Playground
JavaScript
var distance=new Array();
distance[0]=150;
distance[1]=100;
distance[2]=50;
distance[3]=70;
var i=-1;
temp=new Array();
while(distance[++i]){
temp[i]=new Array();
temp[i][0]=i;
temp[i][1]=distance[i];
}
function indexsort(a,b){
return (a[1]>b[1])?1:-1;
}
temp.sort(indexsort);
max=temp.length-1;
alert("indexe distance mini "+temp[0][0]+"\nindexe distance max "+temp[max][0])