javascript sort sparse array keep indexes
Here’s one approach. It copies the defined array elements to a new array and saves their indexes. It sorts the new array and then puts the sorted results back into the indexes that were previously used. var a = []; a[0] = 3; a[1] = 2; a[2] = 6; a[7] = 4; a[8] = 5; … Read more