I have a list of names which I would like to sort by the last number in ascending order.
[1] "W2345_S-001-R1_1.csv" "W2346_S-001-R1_10.csv"
[3] "W2347_S-001-R1_2.csv" "W2348_S-001-R1_9.csv"
[5] "W2345_S-001-R2_1.csv" "W2346_S-001-R2_10.csv"
[7] "W2347_S-001-R2_2.csv" "W2348_S-001-R2_9.csv"
I would like to arrange them by R1 then R2. Within R1 or R2, it should be arranged as 1, 2, 9, 10. Hence the output should be
1] "W2345_S-001-R1_1.csv" "W2346_S-001-R1_2.csv"
[3] "W2347_S-001-R1_9.csv" "W2348_S-001-R1_10.csv"
[5] "W2345_S-001-R2_1.csv" "W2346_S-001-R2_2.csv"
[7] "W2347_S-001-R2_9.csv" "W2348_S-001-R2_10.csv"