On 17 Sep 2005 11:01:41 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
>
>> or tell sorted what to do ;-)
>>
>> >>> original= {
>> ... 'hello':135,
>> ... 'goodbye':30,
>> ... 'lucy':4,
>> ... 'sky':55,
>> ... 'diamonds':239843,
>> ... 'yesterday':4 }
>> >>> list(sorted(
Bengt Richter wrote:
> or tell sorted what to do ;-)
>
> >>> original= {
> ... 'hello':135,
> ... 'goodbye':30,
> ... 'lucy':4,
> ... 'sky':55,
> ... 'diamonds':239843,
> ... 'yesterday':4 }
> >>> list(sorted(original.iteritems(), None, lambda t:t[1], True))
> [('diamonds', 239843), ('hell
On Fri, 16 Sep 2005 21:42:40 +0200, Irmen de Jong <[EMAIL PROTECTED]> wrote:
>JerryB wrote:
>> Hi,
>> I have a dictionary for counting ocurrences of strings in a document.
>> The dictionary looks like this:
>>
>> 'hello':135
>> 'goodbye':30
>> 'lucy':4
>> 'sky':55
>> 'diamonds':239843
>> 'yesterd
You can't sort dictionaries (as implemented by hash tables), they are
unordered data types, so by definition there's no way to force an order
on them.
http://en.wikipedia.org/wiki/Hash_tables
--
http://mail.python.org/mailman/listinfo/python-list
JerryB wrote:
> Hi,
> I have a dictionary for counting ocurrences of strings in a document.
> The dictionary looks like this:
>
> 'hello':135
> 'goodbye':30
> 'lucy':4
> 'sky':55
> 'diamonds':239843
> 'yesterday':4
>
> I want to print the dictionary so I see most common words first:
>
> 'diamond
Hi,
I have a dictionary for counting ocurrences of strings in a document.
The dictionary looks like this:
'hello':135
'goodbye':30
'lucy':4
'sky':55
'diamonds':239843
'yesterday':4
I want to print the dictionary so I see most common words first:
'diamonds':239843
'hello':135
'sky':55
'goodbye':3