Here's a way to do it using split within a Schwartzian Transform:

#!/usr/bin/perl use strict; use warnings; my @data = <DATA>; # Schwartzian Transform print map { $_->[0] } sort { $a->[1][1] <=> $b->[1][1] or $a->[1][0] <=> $b->[1][0] } map { [ $_, [ (split m/,/, $_, 3)[0, 1] ] ] } @data; __DATA__ 1,64,1.4.5,1.4.6,44642850,44642850,0,27348,10028,59188,1488095,761904. +64 1,128,1.4.5,1.4.6,25337850,25337850,0,19236,10276,28196,844595,864865. +28 1,256,1.4.5,1.4.6,13489200,13489200,0,17792,11372,17832,449640,920862. +72 1,512,1.4.5,1.4.6,6996270,6996270,0,18084,16744,19124,233209,955224.06 +4 1,1024,1.4.5,1.4.6,3557880,3557880,0,31528,20488,35188,118596,971538.4 +32 2,64,1.4.5,1.4.6,44642850,44642850,0,25828,9548,40128,1488095,761904.6 +4 2,128,1.4.5,1.4.6,25337850,25337850,0,27936,10796,28696,844595,864865. +28 2,256,1.4.5,1.4.6,13489200,13489200,0,12852,10692,13332,449640,920862. +72 2,512,1.4.5,1.4.6,6996270,6996270,0,17184,15904,18844,233209,955224.06 +4 2,1024,1.4.5,1.4.6,3557880,3557880,0,34068,17948,36628,118596,971538.4 +32

UPDATE: If you prefer regular expression pattern matching to split-ting in this case, just replace the initial map with this:

map { [ $_, [ m/^(\d+),(\d+)/ ] ] }

In reply to Re: numeric sort on substring by Jim
in thread numeric sort on substring by Anonymous Monk

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.