I am trying to order the words of a string in a particular way: In my code below the output is "MNWdeorwy" but i would like it to be "deMNorWwy" (so i need to keep the letters ordered despite being upper o lowercases) Could you please help me to understand where I am wrong and why? Thank you
wrd = "MyNewWord"
def order_word(s):
if s == "":
return "Invalid String!"
else:
c = sorted(s)
d = ''.join(sorted(c))
return d
print order_word(wrd)
I would like to precise that my question is different from the following: How to sort the letters in a string alphabetically in Python : in fact, the answers given in the link does not consider the difference between upper and lowercases in a string.