On Fri, Sep 28, 2012 at 8:29 PM, Ian Kelly <span dir="ltr"><<a href="mailto:ian.g.kelly@gmail.com" target="_blank">ian.g.kelly@gmail.com</a>></span> wrote:<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The slicing operation in the second line assumes that they're all<br>
collected at the end of the list anyway.<span class="HOEnZb"><font color="#888888"><br>
</font></span></blockquote></div><div><br></div><div><br></div><div>True enough. Hadn't considered otherwise when I first whipped that off with the first example (thinking/trying it out *before* posting would likely be a good idea ;)).</div>
<div><br></div><div><div>>>> a = ['z'*5, 'b', 'a', 'c', 'z'*5]</div><div>>>> b = filter(lambda n: n == a[-1], a)</div><div>>>> c = filter(lambda n: n != a[-1], a)</div>
<div>>>> d = sorted(c) + b</div></div><div>['a', 'b', 'c', 'zzzzz', 'zzzzz']</div><div><br></div><div>It does the trick for what he was asking in the original question, although there are likely more optimal solutions for a sufficiently large a.</div>
<div><br></div><div>As Steven noted, it definitely would help to get a little more information about the specific problem.</div>