I'm having a trouble with my school project. I was asked to use a linked list, I'm almost finish but then I got stuck in how do I sort my data by looking at the date

I want to display these data by sorting the date

I have searched everywhere and I still can't find how to sort a linked list multiple parameters
say these are the parameters:

```
struct Data { 
    int kode;           
    char variety[20];   
    int weight;             
    int date;       
    struct Data *next;  
} *headIn, *tempIn;

```

with a `main` function like this:

```
int menu;                               
int pointIn = 0;    
int amount = 0;             
void insert(int kode, char *variety, int weight, int date);
void userInput();
void printList(struct Data *tempIn);  

int main() { 
    headIn = NULL;
    int menu = 0; 

    do {   
        system ("cls");
        printf( " \n\nMAIN MENU :\n");
        printf( " 1. Input Product\n\n");
        printf( " 2. Print List\n\n");
        printf( " enter your choice (1 - 2) : "); 
        scanf("%d", &menu); 

        if (menu < 1 || menu > 2) {
            system("cls");
            printf ("your input is not available\n");
            getch();
        }
        switch (menu) { 
        case 1:
            userInput();
            break;
        case 2:
            printList(tempIn); 
            break;
        }
    }

    while (menu != 3);
    system("cls");
    printf ("============ Thankyou ============");

    return 0;
}

```

and then I apply this function so that the data is going to be a linked list:

```
void insert(int kode, char *variety, int weight, int date) {
    struct Data *dataIn = (struct Data *)malloc(sizeof(struct Data));
    dataIn->kode = kode;
    strcpy(dataIn->variety, variety);
    dataIn->weight = weight;
    dataIn->date = date;
    dataIn->next = NULL;

    if (headIn == NULL) {
        headIn = dataIn;
    } else {
        dataIn->next = headIn;
        headIn = dataIn;
    }
}

```

and then I have this 2 function for asking user's input and the other is for printing

```
void userInput() { 
    int code; 
    int weight;
    int date;
    amount = 0;
    char variety[5][20] = { "Fish", "Crab", "Squid", "Clam", "Lobster" };

    system ("cls");
    printf("Number of data you want to enter : "); scanf("%d", &amount);
    printf( "_________________________________________________________________\n");
    printf("\n Kode 0 = Fish \n kode 1 = Crab \n kode 2 = Squid \n kode 3 = Clam \n kode 4 = Lobster\n\t\t\t   ");

    for (int i = 0; i < amount; i++) {  
        printf("\n\nProduct-%d", pointIn + 1);
        printf("\n\tInput code\t : "); scanf(" %d", &code); 
        if (code < 0 || code > 4) { 
            printf ("this code product is not available\n");
            i--;
        } else {                
            printf("\tJenis\t\t : %s\n", variety[code]);
            printf("\tINPUT weight\t : "); scanf(" %d", &weight ); 
            printf("\tInput date (YYYYMMDD)\t : ");scanf(" %d", &date); 
            pointIn++;
            insert(code, variety[code], weight, date);
        }
    }
    getch();
}

void printList(struct Data *tempIn) {
    system ("cls");
    tempIn = headIn;

    //sort function here

    printf("*****  DATA PRODUCT ***** \n" );
    printf("|  DATE  |  CODE  |      NAME      |  WEIGHT | \n");

    while (tempIn != NULL) {
        printf("    %d        %d     %s          %d        \n", tempIn->date, tempIn->kode, tempIn->variety, tempIn->weight);
        tempIn = tempIn->next;
    }
    getch();
}

```

please help me I don't understand and I can't find any references, it's just this sorting part I'm stuck in.