I have to sort the content of 2 files in such a way that I must first sort it by the dates and then within each subgroup sort them also by times. I tried achieving this by simply using
sort -k 2
and then
| sort -k 3
The 2nd line contains the dates and the 3rd one contains the times. The problem is that instead of actually sorting the values in each subgroup, after the second sort command, it just rearranges all the values only by the times, ignoring the previous sorting completely. For example, say I have the following input:
name1 3.5. 10:00
name2 3.5. 11:00
name3 3.5. 8:00
name4 4.5. 13:00
name5 5.5. 7:00
I would like to sort them by the times they have in each subgroup separately while the dates remain in the same order:
name3 3.5. 8:00
name1 3.5. 10:00
name2 3.5. 11:00
name4 4.5. 13:00
name5 5.5. 7:00
It would also be very helpful if the solution can be written in one line (using | for example).
Thank you in advance.
UPDATE:
I tried using sort -k2,2 -k3,3 but for whatever reason it STILL doesn't work! It sorts the dates correctly, but the times are out of order. If I add -n at the end, it sorts the times correctly, but then the dates are out of order... I even tried sorting the dates normally and the times numerically: sort -k2,2 -k3,3n but it STILL sorts only the dates correctly, while the times still remain out of order. I don't know what else to do. This is killing me...