Code to select the ith order element from a list