I want to use the one built into Perl with maximum speed and support for internationalization... At an absolute minimum, I need a char that I can replace space with -- which will be less than all alphanumeric chars in P-SQL.

Now that you've shown an example, it does seem very strange that P-SQL's "order by" behaves like that. If you are using a perl script for both storing to and fetching from P-SQL, you might try replacing spaces with a control character -- e.g. do  tr/ /\x1a/ on the strings before loading the data into the table, and then  tr/\x1a/ / on the strings after you pull them back out from the table.

But I don't have a P-SQL system available to test this on... maybe it would ignore control characters the same way it ignores spaces. If so, you have to figure out whether you can use something like "/" or "*" or "#" or "%" as a replacement for spaces -- whatever will "stick" during the P-SQL sorting, but is not already present in the original data.

Is there too much of this data to be held in memory at one time? If the perl script that loads the table has all the data in one array or whatever, you could create your table like this:

create table s ( a varchar(255), o int ); # insert the string and its numeric sort order as set by perl's sort select a from s order by o;

In reply to Re^3: Postgresql and space characters by graff
in thread Postgresql and space characters by BerntB

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.