Following function are used to insert the data in sorted Doubly linked list:
void insertion(int n)
{
struct node *ptr=first,*cpt,*newp;
while(ptr->data< n)
{
cpt=ptr;
ptr=ptr->next;
}
newp=(struct node*)malloc(sizeof(struct node));
newp->data=n;
cpt->next=newp;
newp->pre=cpt;
newp->next=ptr;
ptr->pre=newp;
}