在网上看到一种排序算法,我是菜鸟,弱弱的问下高手
这个算法叫什么名字啊!!怎么以前都没怎么看见过?在网上无意看到的,跪求高手......
代码如下:
private int[] GetNum;
/// <summary>
/// int数组升序排列
/// </summary>
/// <param name="NodeNum">源数组</param>
/// <returns></returns>
private int[] GetIntListOrderBy(int[] SourceNum)
{
GetNum = new int[SourceNum.Length];
for (int i = 0; i < SourceNum.Length; i++)
{
int NewPosion = 0;
int Num = SourceNum[i];
for (int j = 0; j < SourceNum.Length; j++)
{
if (Num > SourceNum[j])
NewPosion++;
else
continue;
}
NextNum(NewPosion, Num);
}
return GetNum;
}
/// <summary>
/// 相同的整数后推一位
/// </summary>
/// <param name="posion"></param>
/// <param name="num"></param>
private void NextNum(int posion, int num)
{
if (GetNum[posion] != num)
GetNum[posion] = num;
else
NextNum(posion + 1, num);
}
------解决方案--------------------
就是冒泡排序的本质,只不过把交换这一块,拿出来单独写了个方法