Meta Interview Question

The optimal way of sorting while traversing an array.