finished ex ch8 buidling and sorting array