我需要创建一个排序方法,该方法将根据名称的字母顺序进行排序。我根本不能使用任何类型的数组。任何帮助,将不胜感激。
SortByCustomerName():此方法将链表按客户名称升序排序。
class LinkedList
{
private Node head; // first node in the linked list
private int count;
public int Count
{
get { return count; }
set { count = value; }
}
public Node Head
{
get { return head; }
}
public LinkedList()
{
head = null; // creates an empty linked list
count = 0;
}
public void AddFront(int n)
{
Node newNode = new Node(n);
newNode.Link = head;
head = newNode;
count++;
}
public void DeleteFront()
{
if (count > 0)
{
Node temp = head;
head = temp.Link;
temp = null;
count--;
}
}
}