This is a simple task, but some how I got confused. Requirement is that sort columns independent of each other. Most of us, who used to excel know that independent sorting of columns is not possible without coding. One can sort manually, but it is cumbersome when you have tons of columns. Let us look at the data what we have, then we can get onto the code.
Data has 10 samples and arbitrary number of pathways found in each sample at that time. Requirement is that at each time point, which sample has highest number of pathways. Data can be downloaded from here.
====================================
$ df1=read.csv("sort_independent.txt", sep="\t", stringsAsFactors = F, strip.white = T)
$ df1 %>% gather(time,v, -sample) %>% arrange(time,desc(v)) %>% select (time, sample, v)
=====================================
 output:
======================================
      time    sample    v
1    Time1  sample_2 1080
2    Time1  sample_3 1032
3    Time1  sample_1  883
4    Time1  sample_5  751
5    Time1  sample_8  731
6    Time1  sample_6  493
7    Time1  sample_9  360
8    Time1 sample_10  334
9    Time1  sample_7  214
10   Time1  sample_4   60
11  Time10  sample_4 1190
12  Time10  sample_2 1127
13  Time10  sample_5 1092
14  Time10  sample_7 1008
15  Time10  sample_8  612
16  Time10  sample_9  583
17  Time10  sample_3  260
18  Time10 sample_10   78
19  Time10  sample_1   20
20  Time10  sample_6   16
===================================
This is pretty simple. However, let us this do this in a complex way so that we will have a list of data frames, one data frame for Time point and sort samples within each data frame (time point)
code:
===================================
$ df1 %>% gather(.,time,v,-sample) %>% split(.$time) %>% map(~select(.,c(1,3)) %>% arrange(desc(v)))
===================================
output:
====================================
$Time1
      sample    v
1   sample_2 1080
2   sample_3 1032
3   sample_1  883
4   sample_5  751
5   sample_8  731
6   sample_6  493
7   sample_9  360
8  sample_10  334
9   sample_7  214
10  sample_4   60

$Time10
      sample    v
1   sample_4 1190
2   sample_2 1127
3   sample_5 1092
4   sample_7 1008
5   sample_8  612
6   sample_9  583
7   sample_3  260
8  sample_10   78
9   sample_1   20
10  sample_6   16
=====================================