I’m trying to reorganize an array based on the first occurrence of a value (thus simulating similar functionality to a circular array.)
For example, in the following array I wish the first occurrence of the value 6 to become the new first element, and prior elements to become the latter:
So:
int[] myArray = {2, 3, 6, 1, 7, 6};
Becomes:
myArray = {6, 1, 7, 6, 2, 3};
What is the “best” way to achieve this?
Should do the trick!
You will need a using
System.Linq;