Skip to content

yasuoka/stralnumcmp

Repository files navigation

stralnumcmp

A comparator for text mixed alphabet and numeric characters in C, Python, Perl, and Lua, which enables sort like the followings:

9km
10km

or

part9.mp4
part10.mp4

GNU has strverscmp(3) in libc(3). strverscmp(3) and this stralnumcmp() are similar, but they differ the way of interpreting strings with leading zeros. strverscmp(3) interprets leading zeros like decimal fractions, more leading zeros is less, but this stralnumcmp() just ignores them. eg., "01" > "002" in strverscmp(3), but "01" < "002" in stralnumcmp(3).

History

  • 2018-03-29 yasuoka
    • On python and lua implementation, comparing a numeric portion and a non numeric port which starts a char less than 0 didn't work properly

About

Compare alphanumeric text in C, Perl, Python, and lua.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published