Is Python Smart Enough to do Sorting like this?

shalendra chhabra shalen_itbhu at hotmail.com
Fri Mar 12 20:26:25 EST 2004


Hi,
I just had  a tryst with python.
I was wondering if python is good enough to do this kind of job -- for it 
has extensive support of string and pattern matching, ordering and list 
handling.

There are 'n' itemsets, the size of n is unknown. The program can count 
itself while scanning.  Each of the n itemset is of the form key: value

{key1: value1, key2:value2, key3, value3, key4: value4 .....}

Is it possible to order this itemset in an increasing order of key: value 
with respect to keys. For example: if
key4>key2>key3>key1
then the resulting ordering should be in such a way:

key4:value4, key2: value2,key3:value3>key1: value1

I plan to do this by storing this whole set of itemset in a vector or map.

Lets say vector v={key1:value1, key2: value2, key3: value3,key4:value4}

Now I wish to apply the sorting over this vector v, such that I have the 
entries in the increasing order with respect to keys in v again.
Can some one point to me how to achieve this with python?
A snippet.....

Thanks,

Shalen

_________________________________________________________________
Protect your PC from viruses. Get in the experts. 
http://www.msn.co.in/pcsafety/ Click here now!





More information about the Python-list mailing list