|P is for Practical|
Re: Dictionary-style sort a la Tcl?by moodster (Hermit)
|on Apr 18, 2002 at 10:35 UTC||Need Help??|
As an exercise, I wrote a new comparison routine for use with sort. It splits each string to be compared into parts and if two parts are both numbers, they will be compared numerically. Whitespace is ignored. A shorter string is considered smaller than a longer (that is, "abc" is smaller than "abcde" ).
Calling this routine optimized would be a blatant lie, and I'm sure a lot of things can be improved. It does work, however, at least for simple input data: