sridhar8183 has asked for the wisdom of the Perl Monks concerning the following question:

how can i sort a the below array.
("MAINUI_PF_4.0.001.8Q.7769","MAINUI_PF_4.0.001.10BA.8669","MAINUI_PF_ +4.0.001.10AV.7890","MAINUI_PF_4.0.001.10AU.1898")
Expected result:
MAINUI_PF_4.0.001.10BA.8669 MAINUI_PF_4.0.001.10AU.1898 MAINUI_PF_4.0.001.10AV.7890 MAINUI_PF_4.0.001.8Q.7769

Replies are listed 'Best First'.
Re: Question on alpanumeric sorting
by Laurent_R (Canon) on Aug 31, 2015 at 14:28 UTC
    Hi,

    So you apparently want this order:

    MAINUI_PF_4.0.001.10BA.8669 MAINUI_PF_4.0.001.10AU.1898 MAINUI_PF_4.0.001.10AV.7890 MAINUI_PF_4.0.001.8Q.7769
    Or, given that the line start is always the same, basically, you want this order:
    10BA.8669 10AU.1898 10AV.7890 8Q.7769
    You obviously are not sorting on the last field, so that the sort key presumably boils down to:
    10BA 10AU 10AV 8Q

    But even with this simplified view of your data to be sorted, I am at trouble figuring out the sorting rules that can lead to such an order.

    Can you please explain your sorting rules?

Re: Question on alpanumeric sorting
by moritz (Cardinal) on Aug 31, 2015 at 14:14 UTC
Re: Question on alpanumeric sorting
by toolic (Bishop) on Aug 31, 2015 at 14:12 UTC
Re: Question on alpanumeric sorting
by Anonymous Monk on Aug 31, 2015 at 16:18 UTC
    In reading the documentation on "perldoc -f sort," especially notice the discussion of sort-comparison functions and the comparison operators (both string and numeric) that can be used within them.