Question: I'm a newbie with C language and I need to make a function to sort an array of struct Student data types (after the element `Student.ime` alphabetically). I am not really sure where to put the pointers so I can return the new array.

```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Student {
    int id;
    char ime[20];
    char prezime[20];
    char brindexa[20];
    struct Datum datum_rodjenja;
};

struct Student sortiraj(struct Student niz[], int vel)
{
    int i, j;
    struct Student tempo;
    tempo = niz[0];
    for(j=0 ; j<vel ; j++)
    {
        for(i=j ; i<vel ; i++)
        {
            if(strcmp(tempo.ime,niz[i].ime)>0)
            {
                tempo = niz[i];
            }
            i++;
        }
        niz[j] = tempo;
        j++;
    }
    return niz;
}

```

The array is stored in a `.txt` file but that is not the problem. One more thing, how do I call the function in the `main()`. I thought maybe like this?

```
niz=sortiraj(niz, vel);

```

Can someone give me any tips please. Thank you.

Answer: 
You seem to be sorting the array in-place, so you don't really need to return it at all. Also, use the standard library function `qsort()`:

```
int cmp(const void *ap, const void *bp)
{
    const struct Student *a = ap, *b = bp;
    return strcmp(a->ime, b->ime);
}

struct Student students[] = { /* whatever */ };
qsort(
    students,
    sizeof(students) / sizeof(studends[0]),
    sizeof(students[0]),
    cmp
);

```

Also, please use English function and variable names.
Since you are passing in a pointer, namely `niz`, you are changing the memory that `niz` points to. This means that you don't *have* to return `niz`. 

However if you want to return `niz` your function's return type must be the same type as `niz`. Currently you have a return type of just `struct Student` so you should be getting a compilation error.