I want to sort a list by last names with the algorithm of Quicksort but when exchanging the elements it does not work, it leaves them as they were

In this part the values of the chains are exchanged

```
void swap(string* a, string* b){

cout<<"A and B are "<<*a<<" - "<<*b<<endl;

string t = *a;
*a = *b;
cout<<" A is ->"<<*a<<endl;

*b= t;
cout<<"B is ->"<<*b<<endl;

}

```

This is where the partition is made. I have noticed that when \* i and \* j take values they are exactly the same names and therefore can not be compared later. It seems strange to me that this list works if it is a number but when it is strings this error occurs.

```
User *i = lower;

```

But this did not work at the end because the program crashed, but if you change the value of the string

```
User* partition(User *lower, User *high){

cout<<"Lower ->  "<<lower->lastname<<endl;
cout<<"High ->  "<<high->lastname<<endl;
string  pivot = high->lastname;
User *i = bajo->prev;
 for (User *j = lower; j != high; j = j->next)
{
    if (j->lastname.compare(pivot)< 0)
    {
        i = (i == NULL)? lower : i->next;
        cout<<"Atention J e I valen ->"<<i->lastname<<" - "<<j->lastname<<endl;
        swap(&(i->lastname), &(j->lastname));
    }
}
i = (i == NULL)? lower : i->lastname; // Similar to i++
swap(&(i->lastname), &(alto->lastname));
return i;
}

```

What am I failing? How can I make it really take the desired value.

EDITED:

This is the source code 

```
#include <iostream>
#include<iomanip>
#include <string>
#include<cstdlib>

using namespace std;

class User
{

public :
    string lastname;
    User *next;
    User *prev;
    User()
    {
        lastname= "";
        next=NULL;
        prev=NULL;

    }
    int empty(User *listt)
    {

        if(listt ==  NULL)
        {

            return 1;
        }
        else
        {

            return 0;
        }

    }

    User *Insert(User *listt, string lastName)
    {

        User *temp = new User();

        if(empty(listt))
        {

            temp->lastname=lastName;
            listt = temp;

        }
        else
        {

            temp->lastname=lastName;
            listt->prev=temp;
            temp->next=listt;
            listt=temp;

        }
        return listt;
    }
    void swap(string* a, string* b)
    {

        string t = *a;
        *a = *b;

        *b= t;

    }
    User* partition(User* lower, User* high)
    {

        cout<<"Lower ->  "<<lower->lastname<<endl;
        cout<<"High ->  "<<high->lastname<<endl;
        string  pivot = high->lastname;
        User *i = lower->prev;
        for (User *j = lower; j != high; j = j->next)
        {
            if (j->lastname.compare(pivot)< 0)
            {
                i = (i == NULL)? lower : i->next;
                swap(&(i->lastname), &(j->lastname));
            }
        }
        i = (i == NULL)? lower : i->next; // Similar to i++
        swap(&(i->lastname), &(high->lastname));
        return i;
    }
    User *Last(User *listt)
    {
        User *temp = listt;

        while(temp && temp ->next)
            temp=temp->next;
        return temp;

    }
    void _quickSort( User* lower, User* high)
    {

        if(high != NULL && lower != high&&lower!= high->next)
        {
            User *p = partition(lower,high);
            _quickSort(lower,p->next); //I change this part
            _quickSort(p->next,high);

        }

    }
    void quickSort(User *listt)
    {
        User *h = Last(listt);

        _quickSort(listt, h);

    }
    User *Display(User *listt)
    {

        if(empty(listt))
        {

            cout<<"List empty"<<endl;

        }
        else
        {

            User *temp = new User();
            temp = listt;
            while(temp!= NULL)
            {

                cout<<"The last name is -> "<<temp->lastname<<endl;
                temp=temp->next;
            }

        }
        return listt;

    }
};

int main()
{

    User *listt = NULL;
    User y;
    bool exit = false;
    int opc;
    string lastName;
    while(!exit)
    {

        cout<<"1.-Insert an element"<<endl;
        cout<<"2.-Sort element-(Quicksort)"<<endl;
        cout<<"3.-Show elements"<<endl;
        cout<<"4.-Exitt"<<endl;
        cin>>opc;
        switch(opc)
        {
        case 1:
            cout<<"Inser your last name"<<endl;
            cin>>lastName;
            listt=y.Insert(listt,lastName);
            system("pause");
            system("cls");
            break;
        case 2:
            cout<<"Sorting...."<<endl;
            y.quickSort(listt);
            system("pause");
            system("cls");
            break;
        case 3:
            cout<<"Display..."<<endl;
            y.Display(listt);
            system("pause");
            system("cls");
            break;
        case 4:
            exit = true;
            break;

        }

    }

}

```