Amazon Interview Question

How to sort a problem