ZombieSquirrel
Member
I've been at this for hours now and can't figure this out
I need to sort a grid in an ascending order.
The grid has 3 columns: an instance name, an instance y value, and an instance x value.
I'm doing this to have my own depth system.
Now, I definitely have to order the grid for the y values,
which is a quick
ds_grid_sort(grid, row, true)
but... some y values are the same! For those, I need to give priority to instances with a larger (or smaller) x value.
Let's say 2 instances are right next to each other, in this way, the left instance will always have priority over the right one, but this can only be done if I sort the x values as well, at least for those instances with the same y value.
A quick example:
row y row x
1 1
2 2
5 3
3 4
2 5
becomes (after sorting y)
I need to sort a grid in an ascending order.
The grid has 3 columns: an instance name, an instance y value, and an instance x value.
I'm doing this to have my own depth system.
Now, I definitely have to order the grid for the y values,
which is a quick
ds_grid_sort(grid, row, true)
but... some y values are the same! For those, I need to give priority to instances with a larger (or smaller) x value.
Let's say 2 instances are right next to each other, in this way, the left instance will always have priority over the right one, but this can only be done if I sort the x values as well, at least for those instances with the same y value.
A quick example:
row y row x
1 1
2 2
5 3
3 4
2 5
becomes (after sorting y)
row y row x
1 1
2 2
2 5
3 4
5 3
OR it becomes
row y row x
1 1
2 5
2 2
3 4
5 3
Notice the region where the y's are 2.
I need to make sure they always get ordered in just the one possibility:
2 2
2 5
(smaller x value gets priority)
So in order to do this, I'd need to define the region where the y values, after being sorted, are the same. Then I need to sort that region only while leaving the rest of the sorted grid intact.
Anyone have an idea?
1 1
2 2
2 5
3 4
5 3
OR it becomes
row y row x
1 1
2 5
2 2
3 4
5 3
Notice the region where the y's are 2.
I need to make sure they always get ordered in just the one possibility:
2 2
2 5
(smaller x value gets priority)
So in order to do this, I'd need to define the region where the y values, after being sorted, are the same. Then I need to sort that region only while leaving the rest of the sorted grid intact.
Anyone have an idea?