Hi Kevin.,
For each line, I split the array using comma [ , ] and stored it in another array @source.
I used the substr function to capture the number to sort.
Perform sorting using alphanumber function which I get in net..
-
-
for($i=0; $i<=$#forsort; $i++)
-
{
-
for($j=0; $j<=$#sorted; $j++)
-
{
-
if ($forsort[$i] eq $sorted[$j])
-
{
-
$newarray[$j] = $source[$i] ;
-
}
-
}
-
}
-
-
#Function to sort
-
sub alphanum
-
{
-
@a = func1($_[0]);
-
@b = func1($_[1]);
-
while (@a && @b)
-
{
-
$a_chunk = shift @a;
-
$b_chunk = shift @b;
-
$test = (($a_chunk =~ /\d/) && ($b_chunk =~ /\d/)) ? $a_chunk <=> $b_chunk : $a_chunk cmp $b_chunk ;
-
return $test if $test != 0;
-
}
-
return @a <=> @b;
-
}
-
sub func1
-
{
-
@chunks = split m{ (?= (?<=\D)\d | (?<=\d)\D ) }x, $_[0];
-
return @chunks;
-
}
-
Now using this code is working fine...
but I am facing one more problem...
after sorting if the data is look like means..
<ce:intra-ref id="10009#s0140"/>234, <ce:intra-ref id="10009#s0150"/>234--255, <ce:intra-ref id="10009#s0134"/>274
<ce:intra-ref id="10009#s0240"/>135, <ce:intra-ref id="10009#s0250"/>255, <ce:intra-ref id="10009#s0234"/>255-270
I have to get output like thi
<ce:intra-ref id="10009#s0140"/><ce:intra-ref id="10009#s0150"/>234--255, <ce:intra-ref id="10009#s0134"/>274
<ce:intra-ref id="10009#s0240"/>135, <ce:intra-ref id="10009#s0250"/><ce:intra-ref id="10009#s0234"/>255-270
Looking any help reg this...
Thanks,