[sort] Sort version-like strings with sort -V

Created on November 30, 2026

Use sort -V to order strings by version. It compares digit sequences numerically, so v1.2 comes before v1.10.

printf '%s\n' v1.10 v1.2 v2.0 v1.9 | sort -V
v1.2
v1.9
v1.10
v2.0

printf places each version on its own line. This option is available in GNU sort. The options on macOS and other systems depend on the sort implementation.

Reference

Shell command sort