How can I modify this list so that all p\'s
appear at the beginning, the q\'s
at the end, and the values in between are sorted alphabetically?
Solution to this question is:
list = ['f','g','p','a','p','c','b','q','z','n','d','t','q'];
noOfPs = [i for i in l if i == 'p'];
noOfQs = [i for i in l if i == 'q'];
resultList= noOfPs + sorted(filter(lambda x:x not in {'q', 'p'}, l))+ noOfQs