How can I sort a Legion query result?

I’m tring to find a way to sort my query result (I want to sort on the y property of the position component) before looping through the result. I’m trying with .sort_by, but it’s unclear to me how to convert the types (if even needed).

let iterator = query.iter(&engine.world).collect::<Vec<_>>().sort_by(|entryA, entryB| entryA.1.y.cmp(entryB.1.y));
for (velocity_option, position, scale, sprites) in iterator {}

How could I sort the query result (on position.y) in the simplest way?