On Fri, Sep 28, 2012 at 8:29 PM, Ian Kelly wrote:
> The slicing operation in the second line assumes that they're all
> collected at the end of the list anyway.
>
True enough. Hadn't considered otherwise when I first whipped that off with
the first example (thinking/trying it out *before* posti
On Fri, Sep 28, 2012 at 6:59 PM, Demian Brecht wrote:
>> f = filter(lambda s: s == a[-1], a)
>
> That line's assuming that the last element may also be found in arbitrary
> locations in the list. If it's guaranteed that they're all contiguous at the
> upper bounds, I'd just walk the list backwar
On Fri, 28 Sep 2012 16:39:33 -0700, dave wrote:
> a = ['a', 'b', x]
> b = sorted(a)
>
> What does x need to be to always be last on an ascending sort no matter
> what 'a' and 'b' are within reason...
How about this?
a = ['a', 'b']
b = sorted(a) + ['whatever you want']
You could also do thi
dave writes:
> What does x need to be to always be last on an ascending sort no
> matter what 'a' and 'b' are within reason...
Why are you trying to do that? It sounds ugly. Just sort the list with
the a's and b's. If you absolutely have to, you could make a class with
comparison methods
On 29/09/12 00:51, dave wrote:
more clearer, this is a more realistic use case:
['awefawef', 'awefawfsf', 'awefsdf', 'zz', 'zz',
'zz']
and the quantity of ''zz'' would be dynamic.
Maybe,
class Greatest:
def __lt__(self, other):
r
> f = filter(lambda s: s == a[-1], a)
That line's assuming that the last element may also be found in arbitrary
locations in the list. If it's guaranteed that they're all contiguous at the
upper bounds, I'd just walk the list backwards until I found one that wasn't
matching rather than filterin
Apparently gmail hates me and my last response didn't get through:
a = ['awefawef', 'awefawfsf', 'awefsdf', 'zz',
'zz', 'zz']
f = filter(lambda s: s == a[-1], a)
l = sorted(lst[:-len(f)]) + f
Now, not 100% sure about efficiency over large sizes of a, but tha
dave於 2012年9月29日星期六UTC+8上午7時51分10秒寫道:
> more clearer, this is a more realistic use case:
>
>
>
> ['awefawef', 'awefawfsf', 'awefsdf', 'zz', 'zz',
> 'zz']
>
>
>
> and the quantity of ''zz'' would be dynamic.
>
>
>
> On Friday, September 28, 2
Maybe
l = filter(a, lambda v: v == a[-1])
sorted(a[:-len(l)]) + l
?
On Fri, Sep 28, 2012 at 4:51 PM, dave wrote:
> more clearer, this is a more realistic use case:
>
> ['awefawef', 'awefawfsf', 'awefsdf', 'zz', 'zz',
> 'zz']
>
> and the quantity of ''zzz
more clearer, this is a more realistic use case:
['awefawef', 'awefawfsf', 'awefsdf', 'zz', 'zz',
'zz']
and the quantity of ''zz'' would be dynamic.
On Friday, September 28, 2012 4:46:15 PM UTC-7, Ian wrote:
>
> > a = ['a', 'b', x]
>
> >
>
> >
On Fri, Sep 28, 2012 at 5:39 PM, dave wrote:
> a = ['a', 'b', x]
>
> b = sorted(a)
>
> What does x need to be to always be last on an ascending sort no matter what
> 'a' and 'b' are within reason... I am expecting 'a' and 'b' will be not
> longer than 10 char's long I tried making x = 'z
11 matches
Mail list logo