Jaime Fernandez del Rio wrote:
... the reasons are starting to pile to fare 2.6 goodbye and move on to 3.0...
If you wait just a bit (TM)*, you'd be better served to move on to
3.1. I think 3.0 is for learning, both for Python developers and
users, and has less "fit and polish" than previous Py
Dhananjay gmail.com> writes:
> I want to sort the data on the basis of 3rd column first and latter want to
> sort the sorted data (in first step) on the basis of 6th column.I tried
> sort() function but could not get the way how to use it.I am new to
> programming, please tell me how can I sor
On Mon, May 25, 2009 at 10:15 AM, Chris Rebert wrote:
> Erm, using a compare function rather than a key function slows down
> sorting /significantly/. In fact, the `cmp` parameter to list.sort()
> has been *removed* in Python 3.0 because of this.
Makes a lot of sense, as you only have to run the
On Mon, May 25, 2009 at 12:51 AM, Jaime Fernandez del Rio
wrote:
> Hi Dhananjay,
>
> Sort has several optional arguments, the function's signature is as follows:
>
> s.sort([cmp[, key[, reverse]]])
>
> If you store your data as a list of lists, to sort by the third column
> you could do something
On Mon, May 25, 2009 at 12:29 AM, Dhananjay wrote:
> Hello All,
>
> I have data set as follows:
>
> 24 GLU 3 47 LYS 6 3.909233 1
> 42 PRO 5 785 VAL 74 4.145114 1
> 54 LYS 6 785 VAL 74 4.305017 1
>
Peter Otten wrote:
rows = data.splitlines()
rows.sort(key=lambda line: int(line.split()[5]))
rows.sort(key=lambda line: int(line.split()[2]))
print "\n".join(rows)
Of course you can also sort in a single step:
>>> rows = data.splitlines()
>>> def key(row):
... columns = r
Dhananjay wrote:
> Hello All,
>
> I have data set as follows:
>
> 24 GLU3 47 LYS 6 3.9092331
> 42 PRO5 785 VAL 74 4.145114 1
> 54 LYS6 785 VAL 74 4.305017 1
> 55 LYS6 785
Hi Dhananjay,
Sort has several optional arguments, the function's signature is as follows:
s.sort([cmp[, key[, reverse]]])
If you store your data as a list of lists, to sort by the third column
you could do something like:
data.sort(None, lambda x : x[2])
For more complex sortings, as the one
Hello All,
I have data set as follows:
24 GLU3 47 LYS 6 3.9092331
42 PRO5 785 VAL 74 4.145114 1
54 LYS6 785 VAL 74 4.305017 1
55 LYS6 785 VAL 74 4.291098 1
5