You should've given all these additional details from the beginning.. Yeah, my method will not work.
So if there are 18 players in the array, and you want to make the formation 5-3-2, what should happen? First 5 DF players move to the top of the array, and the reserve DF players (if there are any) should stay in the end of the array? Or you need to remove all reserve players, only leaving 10 people in the array?
I think it would be easier to copy records to another array.
Or even easier if you had sprite instances instead of the array. 18 instances, you pick all DF, mark first 5 of them as selected for the game. Then pick all MD players, select 3 of them, then pick AT player, select 2 of them.