Note. I am using javascript code according to ajrwhite answer. Hope this helps someone.
Link: http://codepen.io/eMineiro/pen/EKrNBe
Open the codepen console to see working examples.
In poker, we determine the position of the player depending on the dealer. Like this:

Blue: small blind and large blind positions
Green: late and dealership / late positions
Yellow: middle position
Pink: early position
So, assuming these two arrays:
players:[1,2,3,4,5,6,7,8,9,10]; positions:["bb","sb","btn","late","medium","medium","medium","early","early","early"];
In this case, “player1” is “Big Blind”, “player2” is “Small Blind”, “player3” is “button” .....
I want to sort an array of players when changePositions (dealer) is called. Example:
changePosition(10); //means that "player10" now is the new Dealer
And the result should be:
players:[2,1,10,9,8,7,6,5,4,3]; positions:["bb","sb","btn","late","medium","medium","medium","early","early","early"];
During the game, players can be eliminated. Therefore, I have a function to exclude the "last position" in the "array of positions" and exclude the player. Then I need to call changePosition (X) again, where X is the next unused player to the left of "player10" (actual dealer).
An example for eliminating "player 1", new arrays should be:
players:[2,10,9,8,7,6,5,4,3]; positions:["bb","sb","btn","late","medium","medium","medium","early","early"];
And I need to call changePosition (X) again to determine new positions, in this case X = 2, since "player2" is to the left of the actual dealer "player10"
changePosition(2);
And it should turn out:
players:[4,3,2,10,9,8,7,6,5]; positions:["bb","sb","btn","late","medium","medium","medium","early","early"];
How can I find a new dealer when I delete a player?
Note. I created a function called changeNextDealer () . A negative index was not a problem because the next dealer is clockwise. It is in the link with the code.
dealerArrayPosition-1;
How to match a negative index, for example -1, with the last position. Or -2 in LastPosition-1? Is there a quick way?
Note. This question still does not answer, but is not the main issue of this discussion. I think they will ask in a separate message.
How do I execute the changePosition (dealer) function?
I've tried so much, but can't figure out how to do this.
Note. I created a function called changePosition () . This is encoded.