Easy problem, I guess, but I can’t work it out.

I have got an array X of data : n lines (objects) and m columns (dimension of the objects) and a list y of n labels, one for each object. How can I sort both X and y on the values of y ?

We can use the Decorate/Sort/Undecorate pattern. In this case, we need to decorate the entries of X with the entries of y. We can use zip() for that. Then sort, and finally remove the decorations.

```
# Untested.
decorated = list(zip(y, X))
decorated.sort()
X = [b for (a, b) in decorated]
```

We can make that a one-liner, and over-write X instead of replacing it:

`X[:] = [b for (a, b) in sorted(zip(y, X))]`