# Is this a well-known ordering algorithm?

I did some practice and implemented some well-known ordering algorithms and I thought that if we look at the list from the side it should look sorted without any work (see the code, it's pretty clear). Pretty sure this has already been accepted / done and I would like to know what is actually called.

This is how I implemented it. and I know it will work badly when the "max-min" content range is large, and maybe only works well on integers. (but it looks very good on very large lists where the content is in a small range (less than 110,000,000 options on my PC (mem started saying no)))

The main reason for getting this name is to look at further improvements and options.

```
void MainWindow(){
for (int a = 0; a < 130000000; a++)
{
rList.Add(rand.Next(1, 110000000));
}
Thread t1 = new Thread(() =>
{
SortYAxis(rList);
});
}
void SortYAxis(List<int> list)
{
int max = int.MinValue;
int min = int.MaxValue;
foreach (int a in list)//Get max/min range
{
if (max < a)
{
max = a;
}
else if (min > a)
{
min = a;
}
}
int[] yList = new int[max - min + 1];
foreach (int a in list)//Flatten along Y axis
{
yList[a - min]++;
}
for (int i = 0, a = 0; i < yList.Length; i++)//Read down Y axis
{
while (yList[i] != 0)
{
list[a++] = i + min;
yList[i]--;
}
}
}
```

source to share

This is a bucket sort . (Your code is pretty much a tutorial implementation.)

The efficiency of bucket sort comes from the fact that it is not a comparison sort - the elements of the array are not compared to each other. Thus, bucket sort can be O (n) and beat the standard O (n log (n)) constraint for which sorting is limited.

The downside (in your opinion) is that bucket sort only works on a finite set, i.e. there must be a finite number of "buckets" that can be created to hold any of the sorted items. Therefore, bucket sort cannot be used as a sorting algorithm for values ββor floating point strings. Also, bucket sorting is large if the "range" of values ββis large. These factors tend to outweigh the benefits of linear complexity, so bucket sorting doesn't really matter.

source to share