Input: list1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'], list2 = [ 0, 1, 1, 0, 1, 2, 2, 0, 1]
Output: [‘a’, ‘d’, ‘h’, ‘b’, ‘c’, ‘e’, ‘i’, ‘f’, ‘g’]
Explanation: Since 'a', 'd' and 'h' have value = 0 in list 2, therefore they occur first, then 'b', 'c', 'e' and 'i' have values = 1 so they occur next and at last occurs 'f' and 'g' which have values = 2.
Input: list1 = ['g', 'e', 'e', 'k', 's', 'f', 'o', 'r', 'g', 'e', 'e', 'k', 's'], list2 = [ 0, 1, 1, 0, 1, 2, 2, 2, 0, 1, 1, 0, 1]
Output: ['g', 'k', 'g', 'k', 'e', 'e', 's', 'e', 'e', 's', 'f', 'o', 'r']
Explanation: Since 'g' and 'k' have value = 0 in list2, therefore they occur first, then 'e' and 's' have value = 1 in list2 so they occur next and at last occurs 'f', 'o' and 'r' which have values = 2.