On Jun 18, 2007, at 7:58 AM, Andrew Brown wrote:
We have a few thousand lines like this
Du Châtelet, Emilie
Du Châtelet, Fred
Du Châtelet, Gustave
Duchâtelet, Emilie
Duchâtelet, Fred
Duchâtelet, Gustave
When sorted with BBEdit, they come out in that order, but we want
the space to be ignored to produce
Du Châtelet, Emilie
Duchâtelet, Emilie
Du Châtelet, Fred
Duchâtelet, Fred
Duchâtelet, Gustave
Du Châtelet, Gustave
Can this be done?
Are any characters ignored by the BBEdit sort?
This can be done pretty nicely with a unix filter that uses a custom
sort routine:
#!/usr/bin/perl -w
my @lines = ();
while (<>)
{
push @lines, $_;
}
print "sorted:\n";
foreach (sort mysort @lines)
{
print "$_";
}
sub mysort
{
my $term1 = $a;
$term1 = lc($term1);
$term1 =~ s/\s//g;
my $term2 = $b;
$term2 = lc($term2);
$term2 =~ s/\s//g;
$term1 cmp $term2;
}
hope this helps,
stephen
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <[EMAIL PROTECTED]>