有关C#数据结构链表排序问题
//链表的排序public void paixu(ref LinkedList a)//a为链表
{
Node tempNode = a.head;
for (int i = 0; i < count + 1; i++)
{
int x = 1;
x = x + i;
for (int j = 0; j < count + 1; j++)
{
if ((int)a.head.item > (int)a.head.next.item)
{
a.head.next.next = a.head .next;
a.head.next = a.head;
}
else
{
continue;
}
if ((int)tempNode.item > (int)tempNode.next.item & tempNode.next.next != null)
{
Node preNode = GetByIndex(x - 1);
tempNode.next = preNode.next;
tempNode = tempNode.next;
tempNode.next.next = tempNode.next;
x++;
}
else
{
x++;
}
if ((int)tempNode.item > (int)tempNode.next.item & tempNode.next.next == null)
{
Node preNode = GetByIndex(x - 1);
tempNode.next = preNode.next;
tempNode = tempNode.next;
}
tempNode = tempNode.next;
}
}