[Solved] Arrange Array values from a matching pattern in C# [closed]


This achieves it in a few lines:

int[] test = {0, 1, 2, 3, 4, 5, 6};
var userValue = 3;
var sorted = test.GroupBy(i => i < userValue).OrderBy(i => i.Key)
            .Select(i => i.OrderBy(j => j)).SelectMany(i => i).ToArray();

Output:

{3,4,5,6,0,1,2}

solved Arrange Array values from a matching pattern in C# [closed]