I have a matrix "acc" arranged by years as rows.
       J     F     M   
1989 438.1 364.9 400.9  
1990 359.3 397.9 272.0  
1991 295.3 309.8 297.8 
If I use apply for sorting the columns R cannot hold the rownames as a matrix, so I need to arrange them them one by one for keeping them like this:
         J                 F                 M
1991   295.3      1991   309.8      1990   272.0
1990   359.3      1989   364.9      1991   297.8
1989   438.1      1990   397.9      1989   400.9
I have to perform a sort function by column but by keeping their rownames, so I am doing many arrays like this:
J<-sort(acc[,1])
F<-sort(acc[,2])
M<-sort(acc[,3])
Is there a way to perform the same operation with a loop and keeping the rownames?
Thank you
 
    