I am loading some data into struct.

```
struct test {
    char x[101];
    char y[101];       
    int z;
};

```

Then I create memory for structs

```
struct test * data;
data = malloc(10 * sizeof(struct test));

```

And fill data like this

```
data[0].z = 123;

```

This works alright. But I wanna sort these structs. Like sort them depending on z attribute.

My idea was to create a new array and fill it with pointers which will point to the right struct.

Can somebody tell me how or if there is better way?

Thanks