This is another job for the Schwartzian Transform. You code is dreadfully inefficient because it does the stripping and case-conversion during every pass through the sort. Try this:
@temp = map {$_->[1]} sort {$a->[0] cmp $b->[0]} map {($da = lc $_) =~ s/[\W_]+//g;[$da,$_]} @temp;

This can be made even more efficient if you know the maximum length of your string. We can use pack to build an intermediary string that we an sort using the low level (in c) default sort. Try this:
@temp = map {(unpack ("A100A100",$_))[1]} sort map {($da = lc $_) =~ s/[\W_]+//g;pack("A100A100",$da,$ +_)} @temp;

Hope this helps

-pete
"I am Jack's utter lack of disbelief"

In reply to Re: dictionary sorting by dreadpiratepeter
in thread [untitled node, ID 151371] by Samn

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.