I've been brooding about this one for some time now: I've got an array of strings with mixed data in it (alphanumerical, punctuation, whitespace). The strings are of variable length. I need to sort that data, but any numbers that show up in the data have to be taken into account. Tcl seems to have such a sort function, and the "lsort -dictionary" man page describes what I'm looking for better than I could...
Use dictionary-style comparison. This is the same as -ascii except (a) case is ignored except as a tie-breaker and (b) if two strings contain embedded numbers, the numbers compare as integers, not characters. For example, in -dictionary mode, bigBoy sorts between bigbang and bigboy, and x10y sorts between x9y and x11y.
I've been rummaging through the archives of "Seekers of Perl Wisdom" as well as Q&A and Google, but all I was able to find were alphabetical sorts (i.e. ignoring case and whitespace).
From what I've seen, the whole problem seems to boil down to finding the right string comparison (which could then be used in sort) - or is that already the wrong approach?
If anyone out there has a solution for this or could at least point me in the right direction, I'd be very grateful...