class Program
{
public delegate bool CompHander(int first, int sencend);
static void Main(string[] args)
{
int[] items = { 12,232,22,4353,323423,11,24,1,4,343};
foreach (int i in items)
Console.Write(i.ToString() + ",");
Console.WriteLine();
//BulletSort(ref items, Number);
BulletSort(ref items, AlpCompare);
foreach (int i in items)
Console.Write(i.ToString() + ",");
Console.ReadKey();
}
public static void BulletSort(ref int[] items,CompHander ComparisonMethod)
{
int temp;
if (items == null)
{
return;
}
for (int i = 0; i < items.Length; i++)
{
for (int j = i; j >=1; j--)
{
if (ComparisonMethod(items[j-1],items[j]))
{
temp = items[j - 1];
items[j - 1] = items[j];
items[j] = temp;
}
}
}
}
public static bool Number(int first, int sencend)
{
return first > sencend;
}
public static bool AlpCompare(int first, int sencend)
{
int comnub;
comnub = (first.ToString().CompareTo(sencend.ToString()));
return comnub > 0;
}
}
{
public delegate bool CompHander(int first, int sencend);
static void Main(string[] args)
{
int[] items = { 12,232,22,4353,323423,11,24,1,4,343};
foreach (int i in items)
Console.Write(i.ToString() + ",");
Console.WriteLine();
//BulletSort(ref items, Number);
BulletSort(ref items, AlpCompare);
foreach (int i in items)
Console.Write(i.ToString() + ",");
Console.ReadKey();
}
public static void BulletSort(ref int[] items,CompHander ComparisonMethod)
{
int temp;
if (items == null)
{
return;
}
for (int i = 0; i < items.Length; i++)
{
for (int j = i; j >=1; j--)
{
if (ComparisonMethod(items[j-1],items[j]))
{
temp = items[j - 1];
items[j - 1] = items[j];
items[j] = temp;
}
}
}
}
public static bool Number(int first, int sencend)
{
return first > sencend;
}
public static bool AlpCompare(int first, int sencend)
{
int comnub;
comnub = (first.ToString().CompareTo(sencend.ToString()));
return comnub > 0;
}
}