-3
我需要創建一個排序方法,將名字排序根據字母順序排列。我根本不能使用任何種類的數組。 任何幫助,將不勝感激。在不使用數組的情況下在鏈接列表類中創建排序方法。 C#
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--;
}
}
}
我想你忘了問一個問題。你怎麼了? –
如何添加一個排序方法到當前鏈表類?使用數組的排序方法背後的邏輯是什麼? –