why it's impossible to sort a string just like a sorting of a c++ array? : <p>can't we sort a string just like a classical sorting(bubble sort or something..) of an array?I tried. But it's not working.</p>

<pre><code>string newstr = "dcba";
for(int i = 0; i &lt; (newstr.size())-1; i++)
    {
        for(int k = i+1; k &lt; newstr.size(); k++)
        {
            if(newstr[i] &gt; newstr[k])
            {
                temp = newstr[i];
                newstr[k] = newstr[i];
                newstr[i] = temp;
            }
        }
    }
</code></pre>
