On 10/17/07, Abandoned <[EMAIL PROTECTED]> wrote:
> Very very thanks everbody..
>
> These are some method..
> Now the fastest method is second..
>
> 1 ===
> def sortt(d):
> items=d.items()
> backitems=[ [v[1],v[0]] for v in items]
> backitems.sort()
> #boyut=len(backitems)
>
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> Without throwing away 500 items:
>
> def sortt(d):
> sorted_items = sorted(d.iteritems(),
> key=operator.itemgetter(1),
> reverse=True)
> return map(operator.itemgetter(0), sorted_ite
I tried these:
def largest_sort(d, n):
return sorted(d, key=d.__getitem__, reverse=True)[:n]
def largest_heap(d, n):
return heapq.nlargest(n, d, d.__getitem__)
def sortt(d):
sorted_items = sorted((item[1], item[0]) for item in
d.iteritems(),
reverse=True)
Abandoned wrote:
> These are some method..
> Now the fastest method is second..
Your four functions return three different results for the same input.
First make sure it's correct, then make it faster (if necessary).
Here are two candidates:
def largest_sort(d, n):
return sorted(d, key=d.__
On Wed, 17 Oct 2007 08:09:50 -0700, Abandoned wrote:
> Very very thanks everbody..
>
> These are some method..
> Now the fastest method is second..
Maybe because the second seems to be the only one that's not processing
the whole dictionary but just 500 items less!?
You are building way too muc
Very very thanks everbody..
These are some method..
Now the fastest method is second..
1 ===
def sortt(d):
items=d.items()
backitems=[ [v[1],v[0]] for v in items]
backitems.sort()
#boyut=len(backitems)
#backitems=backitems[boyut-500:]
a=[ backitems[i][1] for i in rang
George Sakkis wrote:
> On Oct 17, 10:06 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
>> Diez B. Roggisch wrote:
>> > Abandoned wrote:
>>
>> >> Hi..
>> >> I have a dictionary like these:
>> >> a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000
>> >> element
>> >> I want to sort
On Oct 17, 10:06 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Diez B. Roggisch wrote:
> > Abandoned wrote:
>
> >> Hi..
> >> I have a dictionary like these:
> >> a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000
> >> element
> >> I want to sort this by value and i want to fir
On Oct 17, 4:06 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> Diez B. Roggisch wrote:
> > Abandoned wrote:
>
> >> Hi..
> >> I have a dictionary like these:
> >> a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000
> >> element
> >> I want to sort this by value and i want to firs
Diez B. Roggisch wrote:
> Abandoned wrote:
>
>> Hi..
>> I have a dictionary like these:
>> a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000
>> element
>> I want to sort this by value and i want to first 100 element..
>> Result must be:
>> [b, a, d, c .] ( first 100 element)
On Oct 17, 3:39 pm, Abandoned <[EMAIL PROTECTED]> wrote:
> Hi..
> I have a dictionary like these:
> a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000
> element
> I want to sort this by value and i want to first 100 element..
> Result must be:
> [b, a, d, c .] ( first 100 elemen
Abandoned wrote:
> Hi..
> I have a dictionary like these:
> a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000
> element
> I want to sort this by value and i want to first 100 element..
> Result must be:
> [b, a, d, c .] ( first 100 element)
>
> I done this using FOR and ITERA
Hi..
I have a dictionary like these:
a={'a': '1000', 'b': '18000', 'c':'40', 'd': '600'} .. 100.000
element
I want to sort this by value and i want to first 100 element..
Result must be:
[b, a, d, c .] ( first 100 element)
I done this using FOR and ITERATOR but it tooks 1 second and this i
13 matches
Mail list logo