Re: How to get a set of keys with largest values?

2007-11-13 Thread DouhetSukd
On Nov 12, 1:07 am, Davy <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a dictionary with n elements, and I want to get the m(m<=n) > keys with the largest values. > > For example, I have dic that includes n=4 elements, I want m=2 keys > have the largest values) > dic = {0:4,3:1,5:2,7:8} > So, the

Re: How to get a set of keys with largest values?

2007-11-13 Thread DouhetSukd
On Nov 12, 1:07 am, Davy <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a dictionary with n elements, and I want to get the m(m<=n) > keys with the largest values. > > For example, I have dic that includes n=4 elements, I want m=2 keys > have the largest values) > dic = {0:4,3:1,5:2,7:8} > So, the

Re: How to get a set of keys with largest values?

2007-11-12 Thread Davy
On Nov 12, 8:54 pm, Jeff <[EMAIL PROTECTED]> wrote: > Why are you doing that with key-value pairs? Why not with the array > module or lists? Hi, The original question is a bit complex. I have to implement a sparse matrix which use a dict of dict implementation. For example, sp_mat = {1:{2:1,3:4}

Re: How to get a set of keys with largest values?

2007-11-12 Thread Duncan Booth
Jeff <[EMAIL PROTECTED]> wrote: > Why are you doing that with key-value pairs? Why not with the array > module or lists? > The original poster asked about a problem with key-value pairs. I just answered his question. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get a set of keys with largest values?

2007-11-12 Thread Jeff
Why are you doing that with key-value pairs? Why not with the array module or lists? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get a set of keys with largest values?

2007-11-12 Thread Duncan Booth
Davy <[EMAIL PROTECTED]> wrote: > For example, I have dic that includes n=4 elements, I want m=2 keys > have the largest values) > dic = {0:4,3:1,5:2,7:8} > So, the the largest values are [8,4], so the keys are [7,0]. > > Is there any fast way to implement this algorithm? > Any suggestions are we

Re: How to get a set of keys with largest values?

2007-11-12 Thread cokofreedom
On Nov 12, 10:07 am, Davy <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a dictionary with n elements, and I want to get the m(m<=n) > keys with the largest values. > > For example, I have dic that includes n=4 elements, I want m=2 keys > have the largest values) > dic = {0:4,3:1,5:2,7:8} > So, th

How to get a set of keys with largest values?

2007-11-12 Thread Davy
Hi all, I have a dictionary with n elements, and I want to get the m(m<=n) keys with the largest values. For example, I have dic that includes n=4 elements, I want m=2 keys have the largest values) dic = {0:4,3:1,5:2,7:8} So, the the largest values are [8,4], so the keys are [7,0]. Is there any