<div class="gmail_quote">
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">> Just being pedantic here :)<br>
<div class="im">><br>> [items[x] for x in [i for i in map(values.index, new_values)]]<br>><br></div>> Is the same as<br>><br>> [items[x] for x in map(values.index, new_values)]<br><br>It's also the same as<br>
<br>   [items[x] for x in [values.index(i) for i in new_values]]<br><br>Which reduces to<br><br>   [items[values.index(i)] for i in new_values]</blockquote>
<div> </div>
<div> </div>
<div>All these variances prove how python amazing is, thanks!</div>
<div> </div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span>(Although 'i' is not a good choice of variable as it represents a<br>value, not an index)<br>
</blockquote>
<div> </div>
<div> </div>
<div>Actually, I think 'i' indeed represents index of each sorted values in original values list</div>
<div> </div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span>Anyway it doesn't work well if the 'values' list has repeated values,<br>e.g.<br>
<br>items = ['spam', 'eggs', 'wafer']<br>values = [3, 7, 3]</blockquote>
<div> </div>
<div>Yes, I didn't even think about this situation!</div></div>
<div>I'm new to python too, as original poster Esmail, there are a lot of things to learn to be a real pythoner:)</div>
<div> </div>