Teacher:In this task, you are given an input list A. You need to extract and sort the unique digits used in the list in ascending order. Return -1 if there is no digit in the list.
Teacher: Now, understand the problem? Solve this instance: ['287', 'p', '31']
Student:
1, 2, 3, 7, 8