I know that the command last | tac is enough, but I want to do it using the sort command. I cannot sort it by column, it always sorts the first one only. Using bash on Arch Linux.
Sort the 'last' output by month
bash;sort;last
Looks like you can't rely on fields, so you'd need to rely on character column         1         2         3         4         5         6         7         1234567890123456789012345678901234567890123456789012345678901234567890123456789stephane pts/0        :0               Fri Aug  1 09:48 - 14:34 (17+04:45)stephane pts/13       :0               Fri Aug  1 16:27 - 13:51 (20+21:24)From that:last | sort -k1.44,1.46M -k1.48,1.49n -k51Note that the M flag to sort on month names is not standard but available in several sort implementations including GNU sort (the one typically found on ArchLinux). Note that sort interprets the month names in the current locale, while last always outputs English month names, so you may want to run sort under LC_TIME=C if in a non-English locale.