Re: problem with Sorting from Array

2011-02-02 Thread Chris Rebert
On Wed, Feb 2, 2011 at 10:30 PM, shanti bhushan wrote: > Dear All, > > funtion "textPosValue " will give me key ,type and pos values from the > arrays. > This an embedded application code . > I want to execute some thing when key ==0 && type ==0 please let me >                if (key ==0 && type

problem with Sorting from Array

2011-02-02 Thread shanti bhushan
Dear All, funtion "textPosValue " will give me key ,type and pos values from the arrays. This an embedded application code . I want to execute some thing when key ==0 && type ==0 please let me know where to put such code i am getting confused with it def textPosValue(data): str_arr1=[" 0",".

Re: problem with sorting

2008-03-28 Thread bearophileHUGS
Duncan Booth: > Both this and raj's suggestion create a single sorted list. Your suggestion > creates two lists: the unsorted one and a separate sorted one. In most > cases the difference is probably insignificant, but if you have a *lot* of > values it might make a difference. The good thing of P

Re: problem with sorting

2008-03-28 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > On Mar 28, 1:57ÿam, raj <[EMAIL PROTECTED]> wrote: >> To ankit: >> >> Well, sort() doesn't return the sorted list. It returns None. Why not >> this straightforward way? >> dvals = dict.values() >> dvals.sort() >> print dvals > > Why not sorted( dict.values() ). > If y

Re: problem with sorting

2008-03-28 Thread castironpi
On Mar 28, 1:57 am, raj <[EMAIL PROTECTED]> wrote: > To ankit: > > Well, sort() doesn't return the sorted list. It returns None. Why not > this straightforward way? > dvals = dict.values() > dvals.sort() > print dvals Why not sorted( dict.values() ). Can it return the right things from the right

Re: problem with sorting

2008-03-28 Thread raj
To ankit: Well, sort() doesn't return the sorted list. It returns None. Why not this straightforward way? dvals = dict.values() dvals.sort() print dvals -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with sorting

2008-03-27 Thread jwelby
On Mar 28, 5:38 am, [EMAIL PROTECTED] wrote: > >>> dict = {'M':3, 'R':0, 'S':2} > >>> print dict > > {'S': 2, 'R': 0, 'M': 3} > > now if I wanted sorted values in list, i am not able to do this>>> print > dict.values().sort() > > None > > it returns None instead of [0, 2, 3] The sort method works

Re: problem with sorting

2008-03-27 Thread Paddy
On Mar 28, 5:38 am, [EMAIL PROTECTED] wrote: > >>> dict = {'M':3, 'R':0, 'S':2} > >>> print dict > > {'S': 2, 'R': 0, 'M': 3} > > now if I wanted sorted values in list, i am not able to do this>>> print > dict.values().sort() > > None > > it returns None instead of [0, 2, 3] Try: from pprint imp

problem with sorting

2008-03-27 Thread ankitks . mital
>>> dict = {'M':3, 'R':0, 'S':2} >>> print dict {'S': 2, 'R': 0, 'M': 3} now if I wanted sorted values in list, i am not able to do this >>> print dict.values().sort() None it returns None instead of [0, 2, 3] -- http://mail.python.org/mailman/listinfo/python-list