[sort] Reverse the sort order

Created on November 30, 2026

Use -r to reverse the comparison order.

printf '%s\n' apple orange banana | sort -r
orange
banana
apple

Add -n to compare numbers numerically. The combination -nr puts the largest number first.

printf '%s\n' 10 2 30 | sort -nr
30
10
2

Reference

Shell command sort