I’m assuming this is homework or something and you are supposed to do this a certain way or something? What are the specifications?
I shortened your code anyway if that helps in any way
p = "Sorting1234"
upper_case = sorted([i for i in p if i.isupper()])
lower_case = sorted([i for i in p if i.islower()])
no = sorted([i for i in p if i.isdigit()])
output = "".join(lower_case + upper_case + no)
print(output)
Or better yet so you don’t have to sort more than once:
p = "Sorting1234"
p = sorted(p)
output = [i for i in p if i.islower()] + \
[i for i in p if i.isupper()] + \
[i for i in p if i.isdigit()]
print("".join(output))
3
solved sorting in the order of lowercase first then uppercase then digits and sorting the digits to with the odd no first [closed]