Well, THANK YOU!!! both to Matt and the other contributors.
The pearl script works fine and the constrain regarding the number ahead the string is not that critical. I'm definitely new to MAC world and I didn't know that pearl could have been used as script for BBEdit. I've helped a friend of mine (I'm a programmer) to solve the problem I've forwarded to you and now I only need to know how to assign the Unix Filter to a key combo in MAC, BBEdit manual doesn't help for this and the Menu->Preference->... custom keys does not directly allow for that and redirect to a Unix Folder palette key assignment...??? BTW, I haven't a MAC to test your suggestion so I have to wait till my friend come to my office to actually put my hands on a MAC and implement the solutions. This is also the reason of my delay in answering to the group. Thank you ALL! Maurizio On Dec 9, 7:43 pm, Matt Martini <[email protected]> wrote: > Maurizio, > > Try this perl script. You can use it from the command line or you can put it > in > > ~/Library/Application Support/BBEdit/Unix Support/Unix Filters/ > > and use it as a filter, and you an assign it to a key combo if you wish. > This would actually be trivial except for your requirement that numbers be > ignored. > > #!/usr/bin/perl > > while ( $line = <> ) { > chomp($line); > $line =~ s| ||g; > @words = split( ',', $line ); > map { ( $words{$_} = $_ ) =~ s|[0-9]||g; } @words; > print join( ', ', sort valuesort keys %words ) . "\n"; > > } > > sub valuesort { > $words{$a} cmp $words{$b}; > > } > > __END__ > > $ echo "orange, apple, pear, 1banana, 2apricot, bombay" | perl > no_num_word_sort.pl > apple, 2apricot, 1banana, bombay, orange, pear > > Good luck, > > Matt > > On Dec 9, 2010, at 2:14 AM, Maurizio Gennaro Cataldo wrote: > > > Hi there, > > > I really do not figure out how to implement a sorting task which involves > > items > > inside a line of text. > > I know that BBEdit is able to sort lines but what I need is something > > different. > > The task is quite simple, let's say we have a line of text containing comma > > separated items, something like: > > > orange, apple, pear, 1banana, 2apricot, bombay > > > and after having selected the whole line I would like to push a combination > > of keys > > (something like cmd+O) or select a script and obtain something like: > > > apple, 2apricot, 1banana, bombay, orange, pear > > > In other words I would like to alphabetically order the comma separated > > items > > inside the line disregarding any optional number that could appear as first > > characters > > at the beginning of some items. > > > Any suggestion will be really appreciated. > > > Best regards -- You received this message because you are subscribed to the "BBEdit Talk" discussion group on Google Groups. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at <http://groups.google.com/group/bbedit?hl=en> If you have a feature request or would like to report a problem, please email "[email protected]" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
