You could sort using a routine to decompose the accented letter to their base characters. Something like this perhaps.
sub deaccent { my $phrase = shift; return $phrase unless ( $phrase =~ y/\xC0-\xFF// ); #short circuit + if no upper chars # translterate what we can (for speed) $phrase =~ tr/ÀÁÂÃÄÅàáâãäåÇçÈÉÊËèéêëÌÍÎÏìíîïÒÓÔÕÖØòóôõöøÑñÙÚÛÜùúûü +Ýÿý/AAAAAAaaaaaaCcEEEEeeeeIIIIiiiiOOOOOOooooooNnUUUUuuuuYyy/; # and substitute the rest my %trans = qw(Æ AE æ ae Þ TH þ th Ð TH ð th ß ss); $phrase =~ s/([ÆæÞþÐðß])/$trans{$1}/g; return $phrase; }
used as:
foreach my $row_db ( sort { deaccent($a) cmp deaccent($b) } @$selected + ) {
foreach my $row_db ( sort { deaccent($a->[1]) cmp deaccent($b->[1]) } +@$selected ) { my ($ID, $column1, $column2) = @$row_db; print "$column1\n"; }
Or as a Schwartzian Transform. (probably not worth it unless @$selected is large)
foreach my $row_db (map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { + [$_, deaccent($_)] } @$selected ) {
foreach my $row_db (map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { + [$_, deaccent($_->[1])] } @$selected ) { my ($ID, $column1, $column2) = @$row_db; print "$column1\n"; }
Note: this only covers ISO-Latin-1, if you need other code pages, modify deaccent() to suit (or possibly use Text::Unidecode)
UPDATE: fixed errors.
In reply to Re: SQLite (DBD) Sorting
by thundergnat
in thread SQLite (DBD) Sorting
by fanticla
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |