I have a list in Prolog like the following:

```
[(b,y,3),(p,z,1),(p,y,3),(b,y,2),(p,z,2),(p,x,3),...]

```

where the first element of the first tuple is in `[b,p]`, the second is in `[x,y,z]`, and the third is in `[1,2,3,4,5,6,7]`.

How do I sort this list of tuples so that the above sample of list becomes:

```
[(b,y,2),(b,y,3),(p,x,3),(p,y,3),(p,z,1),(p,z,2),...]

```

that is, b comes before p, x before y and z and the numbers are sorted.