in reply to Scientific notation problem

It depends mostly on the method you use to sort. A plain string sort, which is the default, will be easily confused because it tries to sort the numbers alphabetically.

Here's what I used, and it worked:
#!/usr/bin/perl my @nums = (2.3e+4, 4e9, 7e-9, 4e-3, 4e-14, 4.4e-14, 4e-13); foreach (sort {$a <=> $b} @nums) { print "$_\n"; }

Replies are listed 'Best First'.
Re: Re: Scientific notation problem
by dorp (Novice) on Aug 13, 2001 at 20:53 UTC
    I did use something similar. I said:
    foreach(sort byval keys %index) { ... } sub byval { return ($score{$a} <=> $score{$b}) }
    Is there a way to force numerical evaluation?
      That should do it, except that you're evaluating %score on the keys of %index, which may just be an error in your example, or something that should work, but isn't clear from your example.

      You can "force numerical evaluation" with the <=> operator.