I built a perl inline::c module, but there is some oddity with the sorting. Anyone know why it would sort like this? Why is the 4.0e-5 is not first?
my $ref = [ 5.0e-5,4.2e-5,4.3e-5,4.4e-5,4.4e-5,4.2e-5,4.2e-5,4.0e- +5]; use Inline C => <<'END_OF_C_CODE'; void test(SV* sv, ...) { I32 i; I32 arrayLen; AV* data; float retval; SV** pvalue; Inline_Stack_Vars; data = SvUV(Inline_Stack_Item(0)); /* Determine the length of the array */ arrayLen = av_len(data); // sort sortsv(AvARRAY(data),arrayLen+1,Perl_sv_cmp_locale); for (i = 0; i < arrayLen+1; i++) { pvalue = av_fetch(data,i,0); /* fetch the scalar located at i + .*/ retval = SvNV(*pvalue); /* dereference the scalar into a numb +er. */ printf("%f \n",newSVnv(retval)); } } END_OF_C_CODE
> test($ref);

0.000042
0.000042
0.000042
0.000043
0.000044
0.000044
0.000040
0.000050

In reply to perl inline::c sorting problem by dalittle

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.