Google interview question

How to code an array to order