I created a sorting algorithm, called Grid Sort Index &amp; Sorting

Index

• Counting: when the index, or the position, is dependent on the item. Count from one. (Zero-based index is mathematically wrong.)

• Grid: when the index, or the position, is independent on the item. (e.g. JavaScript array)

Counting arrays are used in bubble sort, merge sort, quick sort, etc. Because of the nature of the index, sorting techniques using counting arrays require comparing the items and moving the items around.

Grid arrays are better suited for sorting.

Grid Sort

• Assigning the number (or other value associated with the number, such as name) to the corresponding index’s item

• Filtering out the undefined for print, iterate, length, etc.

• Assigning is sorting

• No comparing. No swapping. No moving around items.

• No need for indexOf()

• Stable

• Limitations : whole numbers only, size of an array

• An example using JavaScript

• https://code.sololearn.com/WWuuXR9rO45U/?ref=app


var test = [57, 285, 0, 854, 0, 27, 5, 5, 2885, 497, 57, 16, 803, 653, 62, 905, 975, 367, 147, 99, 58, 207643, 73, 83, 95, 24, 3, 1986, 47, 954, 1, 99, 954, 36, 67, 2, 753, 97, 3689, 79864, 5788, 479, 9865, 8900, 73, 753, 588, 19537, 489964, 30674, 578, 55, 99999, 578, 1000000, 58, 279, 3, 75, 975, 46, 785, 6789, 164, 5538, 744, 85, 2, 579, 753, 5538, 975, 158, 689, 379, 965, 57, 803, 84, 653, 85, 73, 864, 8643, 9047, 864, 783, 7, 4, 932, 5, 80, 97, 79, 849, 7, 3, 5, 10, 0];

document.write(test+”&lt;br /&gt;”);
document.write(“Count: “+test.length+”&lt;br /&gt;”);
document.write(“&lt;br /&gt;”);

var test_original = [];
var x = 0;
while (x &lt; test.length){
    if (test_original[test[x]] === undefined){
        test_original[test[x]] = [];
        test_original[test[x]][0] = test[x];
    }
    else{
        test_original[test[x]].push(test[x]);
    }
    x = x + 1;
}

var test_defined = [];
var defined_from = 0;
var defined_to = test_original.length;
var x = defined_from;
while (x &lt; defined_to){
    if (test_original[x] !== undefined){
        test_defined.push(x);
    }
    x = x + 1;
}

var definedIndex = 0;
while (definedIndex &lt; test_defined.length){
    document.write(definedIndex + 1);
    document.write(“. “);
    document.write(test_defined[definedIndex]);
    document.write(“: “);
    document.write(test_original[test_defined[definedIndex]]);
    document.write(“&lt;br /&gt;”);

    definedIndex = definedIndex + 1;
}
Zero based indexing

Counting: when the index, or the position, is dependent on the item. Count from one. (Zero-based index is mathematically wrong.)

I will disagree. The index does not represent a count but rather it is a position. When we measure something we start at 0. For example a length of 5 units. Unit 0 the 1st unit is at 0 to &lt; 1, and the last unit, the 5th is at 4 to &lt; 5. The set of 5 units does not contain the unit 5.
It is not mathematically wrong to use zero based indexing, what is wrong is using the index to represent a count.
Array V Grid AKA hash table

Grid: when the index, or the position, is independent on the item. (e.g. JavaScript array)

I think you understanding of how arrays work is leading to some bad assumptions.
Arrays
Computers use RAM that is a continuous array of addresses. We use arrays because they are very fast when we need to get or set a item at an index.
To locate an item we get the RAM address of the array and add the index multiplied by the size of each item (JS arrays hold references so all array items are the same size) . In one addition and multiplication (a shift if item size is a power of two) we have the memory address of the data we want.
Almost all modern CPUs have special instructions (indexed addressing) to speed up array use.
Hash table
A grid is a little more complicated.
As the index can be any value we can not just offset a RAM address to find an item. We need to know where the item associated with an index is in RAM. That means that another array is needed to hold all the indexes and RAM addresses.
So if you want the item of grid index 10000000, we need the address of the index 10000000 which must be found by searching the array of indexes one at a time. Then we can get the RAM offset of the item we are after.
However computers have been around for a long time and some cleaver people have come up with ways to make &quot;grids&quot; somewhat faster. In javascript we call them Map
in computer science we use the term hash table.
Hash tables avoid the need to search for the index by applying a hash function to the index (key). This provides an offset that we can use to get the RAM address of the data we are after.
Still slower than an array as the hash function needs to be applied each time we index into the table, its a lot faster than searching all indexes each time we want an item.
When JS arrays are not arrays.
On a side note. JavaScript arrays come in two flavors

Dense arrays, each item is held one after the other in a continuous section of memory.
Sparse arrays. Sparse arrays look from the code perspective like dense array, but under the hood sparse array are actually hash tables.

A dense array is converted to a sparse array if you add an item above the array length. Different engines have different rules but generally its a bad idea to add items to an array at random indexes (as you do in your grid sort)
Review
I am not going to review your code as I think it is moot if you consider the above information.
I will say, you saw some institutionalized flaws and you created a better solution (sadly your assumptions were off). You demonstrate an initiative and a healthy skepticism of the status quo.
Most people will just keep at the same old same old and nothing great ever comes from that.
Keep at it.