in reply to sorting the numbers with strings
You might also consider using Schwartzian Transform or Orcish Manœuvre.#!/usr/bin/perl use warnings; use strict; my $string = 'p(0)=0,35 p(1)=0,54 p(2)=0,12 p(3)=0,96 p(4)=0,43'; print join ' ', map { s/\./,/; $_ } sort { my ($x, $y) = map { s/,/./; /=(.*)/; $1 } $b, $a; $x <=> $y } split / /, $string; print "\n";
|
|---|