Skip to content
Back to formatted view

Raw Message

Message-ID: <2402860e0905270539i1dded0b6la619c6d0d31fc2ac@mail.gmail.com>
Date: 2009-05-27T12:39:23Z
From: Paul Geeleher
Subject: Sort matrix by column 1 ascending then by column 2 decending

I've got a matrix with 2 columns and n rows. I need to sort it first
by the values in column 1 ascending. Then for values which are the
same in column 1, sort by column 2 decending. For example:

2 .5
1 .3
1 .5
3 .2

Goes to:

1 .5
1 .3
2 .5
3 .2

This is easy to do in spreadsheet programs but I can't seem to work
out how to do it in R and haven't been able to find a solution
anywhere.


Thanks!

-Paul.

-- 
Paul Geeleher
School of Mathematics, Statistics and Applied Mathematics
National University of Ireland
Galway
Ireland