Sort a nearly sorted array | Citadel Interview Question