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>