This is because you are getting the iterator and sorting it.
The method getIterator
creates a new ArrayIterator
which makes a copy of the array.
Then, you are returning the collection, which is not sorted.
Here is a little sample of what happens.
You just have to replace
return $collection;
By
return $iterator;