You are not logged in.

#1 2013-03-22 16:39:36

jjacky
Member
Registered: 2011-11-09
Posts: 321
Website

Natural Sorting utility

So recently I was trying to sort things using natural order in C, and it turns out to be more complicated than would have been nice. For those interrested (if any), more details about all this can be found here.

Anyhow, in the end I did write a function to implement natural sort order, and made a little tool to try it out: natsort. It will read lines from stdin and print them sorted on stdout. Supported options are natural order obviously, also case sensitivity and a few more things due to the fact that I meant this to be used for filenames mostly, so having lines starting with a dot put first, or mixed with the rest.

The major flaw of this being that is isn't locale-based, so accents and such will not be treated properly/as expected, but as with basic comparisons will be put after the rest.

Anyhow, source code on github & PKGBUILD in the AUR.
-j

Offline

Board footer

Powered by FluxBB