|XP is just a number|
Re: Re: Dictionary-style sort a la Tcl?by argathin (Acolyte)
|on Apr 18, 2002 at 12:56 UTC||Need Help??|
First of all: A big THANKS to all who responded! The solutions offered by ariels and Juerd seem to come the closest to what I need (BTW: Thanks for pointing out that I need to rethink my requirements!). blakem's solution probably won't work, as I can't make the assumption mentioned by him about the data I get and moodster's solution doesn't seem to work for all cases (though I didn't quite find out why).
In any case, I learned a few more things, which is good... :-)
As for Juerd's code:
There's also a second problem, but that's partly due to my apparently incomplete requirements - I wasn't aware of that until I experimented a bit with the solutions offered here. Take the following data set:
Unsorted:x10y 1abc a10y x9y b1 abc DEF 123DEF bigboys big9boys 123DEFG 123defUsing your code or ariels' code, the result is:
Sorted:1abc 123DEF 123def 123DEFG a10y abc b1 big9boys bigboys DEF x9y x10y
Whether "big9boys" should appear before "bigboys" is probably debatable - I'm not 100% sure myself wich way round would be better in my case...