UPDATE: Bug fix is uploaded. See below

If anyone has experience with the Sort::Key::Radix library, I would appreciate your input to see if I'm doing something blatantly wrong or if there's a bug in one of the methods I'm using.

I have an array of (uniform-length) hexadecmial strings:

@hexStr = ("339E84CBCF3C7", "2739E84CBCF3C", ...);

I would like to sort them and return a list of the sorted *indices* rather than just a list of the sorted hex strings. I used the keysort method from the author's non-Radix-based sorting library (Sort::Key::keysort) to successfully sort them with:

my @sortedIdx = keysort { $hexStr[$_] } (0..$#hexStr);

I would prefer to sort with Sort::Key::Radix method because it is *MUCH* faster (when using the working "ssort" method on strings directly) than other sort methods I've used and it seemed rather straight-forward:

my @sortedIdx = skeysort { $hexStr[$_] } (0..$#hexStr); # line 58

But I get a bunch of errors:

Argument "273D09979E78F" isn't numeric in array element at sortHexIndi +ces.pl line 58. Use of uninitialized value in subroutine entry at sortHexIndices.pl li +ne 58. Argument "339E84CBCF3C7" isn't numeric in array element at sortHexIndi +ces.pl line 58. Argument "39CF4265E79E3" isn't numeric in array element at sortHexIndi +ces.pl line 58. Argument "1CE7A132F3CF1" isn't numeric in array element at sortHexIndi +ces.pl line 58. Argument "0E73D09979E78" isn't numeric in array element at sortHexIndi +ces.pl line 58. Argument "2739E84CBCF3C" isn't numeric in array element at sortHexIndi +ces.pl line 58. Argument "339CF4265E79E" isn't numeric in array element at sortHexIndi +ces.pl line 58. Use of uninitialized value in subroutine entry at sortHexIndices.pl li +ne 58. Argument "39CE7A132F3CF" isn't numeric in array element at sortHexIndi +ces.pl line 58. Argument "3CE73D09979E7" isn't numeric in array element at sortHexIndi +ces.pl line 58. Argument "1E739E84CBCF3" isn't numeric in array element at sortHexIndi +ces.pl line 58. Argument "0F39CF4265E79" isn't numeric in array element at sortHexIndi +ces.pl line 58. Argument "279CE7A132F3C" isn't numeric in array element at sortHexIndi +ces.pl line 58. Use of uninitialized value in subroutine entry at sortHexIndices.pl li +ne 58. Argument "33CE73D09979E" isn't numeric in array element at sortHexIndi +ces.pl line 58. Argument "39E739E84CBCF" isn't numeric in array element at sortHexIndi +ces.pl line 58.

I thought Sort::Key::Radix::skeysort would be appropriate for sorting strings, hence the "s". Am I doing something wrong or does this appear to be a bug?

Thanks!

In reply to Sort::Key::Radix::skeysort bug or user error? by traceyfreitas

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.