I have a matrix
df<-matrix(data=c(3,7,5,0,1,0,0,0,0,8,0,9), ncol=2) rownames(df)<-c(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\") [,1] [,2] a 3 0 b 7
The order function should do it.
order
df[order(df[,1],df[,2],decreasing=TRUE),]