Drag and drop with position

Hi ! I will need help, advice and examples please!

I would like to be able to drag/drop objects into an area, and if one of the objects overlaps another already in the area, they shift to make room based on a number they have.

Let’s say I have a list of 50 objects, each having a numeric variable from 1 to 50. In a dedicated area, I can drop these objects, and they should be placed in ascending order.
If in the zone I have:
12 - 25 - 38
And I want to position the 20, so either we shift 12 to the left, or the 25 and 38 to the right, to place the 20 between the 12 and the 25.

If we place it between 25 and 38, we display “lost” and the 20 positions itself in its place for example.

I saw this example with maps, it might look similar in idea, but I can’t figure out how to do it with the ideas I have in mind :

Thanks for your help !