Could you help me ?
I have array of objects:
[
{
position: {x: 2, y: 3}
...
},
{
position: {x: 5, y: 5}
...
},
{
position: {x: 5, y: 5}
...
}
]
I need a function that will change the coordinates so that elements with the same position move down the y-axis
For exampple
[
{
position: {x: 2, y: 3}
...
},
{
position: {x: 5, y: 5}
...
},
{
position: {x: 5, y: 6} <= changed
...
}
]
The main difficulty for me is that when the element is shifted down along the y-axis, the position may again coincide with some other element
[
{
position: {x: 2, y: 3}
...
},
{
position: {x: 5, y: 5}
...
},
{
position: {x: 5, y: 6}
...
}
...
{
position: {x: 5, y: 6} <= not again !
...
}
]