Python: How to sort the letters in a string alphabetically keeping distinction between uppercases and lowercases
<p>I am trying to order the words of a string in a particular way: In my code below the output is <em>"MNWdeorwy"</em> but i would like it to be <em>"deMNorWwy"</em> (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</p>

<pre><code>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)
</code></pre>

<p>I would like to precise that my question is different from the following: <a href="https://stackoverflow.com/questions/15046242/how-to-sort-the-letters-in-a-string-alphabetically-in-python">How to sort the letters in a string alphabetically in Python</a> : in fact, the answers given in the link does not consider the difference between upper and lowercases in a string.</p>