drieux wrote: > Ironically, uh, duh, given tassilo's recent thumping > of me for whining about acadamia - there are some > ugly 'sorting algorithms' that have to be 'ugly' > to be 'general enough' that are, well, ugly.
Hmmm. I don't know about that. Most sorting algorithms I have seen are quite beautiful conceptually. Even the rather primitive bubble sort can look pretty viewed in its single dimension. Each of the recursive algorithms has its own style of elegance. The mechanics of dealing with various types or shapes of data can usually be abstracted with a function call: my @sorted = sort {shape_to_fit($a, $b)} @source; I do see something like this when it comes to storage structure, though. I love Balanced Tree structures from a conceptual perspective, for instance, because I see a real elegance in them. Still I cannot ignore the difference between their O(log n) times and the O(1) time characteristic of the hash. To me hashes are like sausage to a carnivore--I love the end product, but have no desire to look too closely at the process. > You might want to get your hands on Knuth's > and crawl the searching and sorting algorithm > sections if you are really interested in some > serious analysis of good ways and bad ways to > think about solving sorting algorithms. > > may I recommend that you peak at > > perldoc -q sort > > and then look at > > @sorted = map { $_->[0] } > sort { $a->[1] cmp $b->[1] } > map { [ $_, uc( (/\d+\s*(\S+)/)[0]) ] } @data; > > and think about what that MIGHT mean were it to > have been plugged into the process. > > ciao > drieux I'm sorta stumped, I must admit. Looks like you have material with a single numeric prefix that is extraneous to your need, and a single token that you are seeking, per line--and that you want it all to SHOUT. I'd suggest abstracting most of this into your shape_to_fit().when looking at it in the context of the sort. Of course, a specific name for the shape_to_fit function would aid comprehension greatly. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>