Meta interview question

The optimal way of sorting while traversing an array.