//排序
void sort(dlist_t head)
{
dlist_t tmp = head->next,p = NULL,q = NULL;
//將鏈表置空
head->next = head;
head->prev = head;
while(tmp!=head){
//保存原鏈表中tmp的下一個節點
q = tmp->next;
//找到tmp插入的位置
for(p=head->prev;p!=head&&p->data>tmp->data;p=p->prev);
//將tmp插入到p之後
tmp->prev = p;
tmp->next = p->next;
p->next->prev = tmp;
p->next = tmp;
//將tmp指向要插入的下一個節點
tmp = q;
}
}