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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.