I would like to know how to sort version numbers, using bash or perl. I would like to sort file names that are program names with version numbers and extensions, such as hello-0.2.3.tar.gz and hello-0.10.3.tar.gz.
Version numbers of computer programs do not comply with the mathematical rule concerning the below-decimal-point part. Mathematics treats the part below decimal point differently from the integral part. In mathematics, the following sort order holds.
0.1 = 0.10 = 0.100 < 0.11 < 0.2 < 0.3
On the other hand, the version numbering system treats the part below decimal point in the same manner as the integral part. In the version numbering system, the following sort order holds.
0.1.0 < 0.2.0 < 0.3.0 < 0.10.0 < 0.11.0 < 0.100.0
The "sort" command on bash fails to achieve this latter result. How can one achieve this latter result?