queue.c
/*
 * Sort elements of queue in ascending order
 * No effect if q is NULL or empty. In addition, if q has only one
 * element, do nothing.
 */
Sort elements of queue in ascending order
No effect if q is NULL or empty. In addition, if q has only one
element, do nothing.
Sort elements of queue in ascending order No effect if q is NULL or empty . In addition if q has only one element do nothing .
void q_sort(struct list_head *head)
{
    if (!head || head->next == head || head->next->next == head)
        return;
    head->prev->next = NULL;
    head->next = mergesort(head->next);
    struct list_head *node = head->next;
    node->prev = head;
    while (node->next) {
        node->next->prev = node;
        node = node->next;
    }
    node->next = head;
    head->prev = node;
}
void q_sort ( struct list_head * head ) { if ( ! head || head -> next == head || head -> next -> next == head ) return ; head -> prev -> next = NULL ; head -> next = mergesort ( head -> next ) ; struct list_head * node = head -> next ; node -> prev = head ; while ( node -> next ) { node -> next -> prev = node ; node = node -> next ; } node -> next = head ; head -> prev = node ; }
Sort elements of queue in ascending order
 No effect if q is NULL or empty.
Sort elements of queue in ascending order No effect if q is NULL or empty .