Comparing text strings

Chris Angelico rosuav at gmail.com
Mon Apr 12 19:57:12 EDT 2021


On Tue, Apr 13, 2021 at 9:54 AM Cameron Simpson <cs at cskk.id.au> wrote:
> Note that this depends on sorting by version. A lexical sort (eg
> "ls|sort") will look good intil a package version crosses a boundary
> like this:
>
>     1.9.1
>     1.10.0
>
> A lexical sort will put those the other way around because "9" > "1".
> Wrongness will ensue.
>

GNU sort has a -V option to sort by version numbers. I don't know how
well that'd handle other tags though.

ChrisA


More information about the Python-list mailing list