To sort in reverse order pass the -r option to sort . This will sort in reverse order and write the result to standard output. Using the same list of metal bands from the previous example this file can be sorted in reverse order with the -r option.
How do I sort a Linux file in reverse order?
-r Option: Sorting In Reverse Order : You can perform a reverse-order sort using the -r flag. the -r flag is an option of the sort command which sorts the input file in reverse order i.e. descending order by default. Example: The input file is the same as mentioned above.
How do you sort a list in reverse order?
Collections. sort() method. This method requires two parameters i.e. the list to be sorted and the Collections. reverseOrder() that reverses the order of an element collection using a Comparator.