find the numerical index of a list of characters in ascending alphabetical order
<p>I am writing a cryptography program that does columnar transposition. 
a person enters a key as a string, eg, key = 'ZEBRAS'
I need to determine the numerical index corresponding to each letter, in ascending alphabetical order. 
for example, </p>

<ul>
<li><strong>Z E B R A S</strong></li>
<li><strong>6 3 2 4 1 5</strong></li>
</ul>

<p>A is the highest, so its rank 1. z is the lowest, so its rank 6. 
I want to store this value into an appropriate data structure, so when i go to encrypt a message, i will read off the column corresponding to position 1 first, and 6 last. </p>

<p>Create a temp list to store the sorted word, and extract the position from the temp list. Below is the sample code:</p>

<pre><code>&gt;&gt;&gt; word = 'ZEBRAS'
&gt;&gt;&gt; sorted_word = sorted(word)

&gt;&gt;&gt; sorted_word
['A', 'B', 'E', 'R', 'S', 'Z']

&gt;&gt;&gt; index_string = [sorted_word.index(a)+1 for a in word]
&gt;&gt;&gt; index_string
[6, 3, 2, 4, 1, 5]
</code></pre>

python sorting cryptography