I think it is not possible using "SORT" key word.

Ummm, have you looked at the documentation for sort? It gives examples of doing just what you want to do, which is to sort an array of data. The code below sorts an array in ascending order and descending order using the sort command.

use strict; use warnings; use Data::Dumper; my (@unsorted) = qw(7 3 2 9 5 18 1 4); my @sorted1 = sort {$a <=> $b} @unsorted; my @sorted2 = sort {$b <=> $a} @unsorted; print Dumper @sorted1; print "---------\n"; print Dumper @sorted2;

   Please forward solution to following mail id-suneeldv@gmail.com

Hmmm....sorry, but I'll pass on that one. I could be wrong, but I'm not too sure how many (if any) monks will be willing to do that. You just might have to come back to the monastery to see if anyone has posted a solution that you like. In other words, I'm willing share a "solution" to your question, but I'm not willing share with you my personal email address.


In reply to Re: Sorting of numbers using arrays by dasgar
in thread Sorting of numbers using arrays by suneeldv

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.