using System;
class Program
{
static int swap(int a, int b) {
return a;
}
static void sort(int[] arr) {
int start = 0;
int end = arr.Length - 1;
int mid = 0;
while (mid <= end) {
switch (arr[mid]) {
case 0: {
arr[start] = swap(arr[mid], arr[mid] = arr[start]);
start++;
mid++;
break;
}
case 1: {
mid++;
break;
}
case 2: {
arr[mid] = swap(arr[end], arr[end] = arr[mid]);
end--;
break;
}
}
}
}
static void Main()
{
int[] arr = {2, 1, 0, 0, 1, 2, 2, 1, 1, 2};
sort(arr);
for (int i = 0; i < arr.Length; i++)
Console.Write(arr[i] + " ");
}
}
/*
run:
0 0 1 1 1 1 2 2 2 2
*/