public string SortAnArrayInParticularOrder(string input)
{
if (string.IsNullOrEmpty(input)) { Console.WriteLine("input string in Empty or null"); return string.Empty; }
var values = input.ToLowerInvariant().ToCharArray();

Console.WriteLine("Before");
Console.WriteLine(string.Join(",", values));
Debug.WriteLine("Before :" + string.Join(",",values));
int[] count = { 0, 0, 0 };
char[] charOrder = { 'R', 'G', 'B' };
int i = 0;

while (i < values.Length)
{
switch (values[i])
{
case 'r':
count[0]++;
break;
case 'b':
count[2]++;
break;
case 'g':
count[1]++;
break;
}
i++;
}
int tempCount = 0;

for (i = 0; i < charOrder.Length; i++)
{
tempCount += count[i];
}
if (tempCount < charOrder.Length)
{

Console.WriteLine("Input String is not valid");
return "";

}
int k = 0;

List resultList= new List();
for (i = 0; i < 3; ++i)
{
for (int j = 0; j < count[i]; ++j)
{
resultList.Add(charOrder[i]);
}
}
Console.WriteLine("After");
Console.WriteLine(string.Join(",", resultList));
Debug.WriteLine("Before : " + string.Join(",", values));
Debug.WriteLine("After : " + string.Join(",",resultList));
return string.Join("", values);
}