in reply to Why didn't this sort?

If you're looking for the array @$outputRef itself to be sorted, you'll have to do something like this:
$outputRef = [ sort @$outputRef ];
When you say sort @$outputRef, you're creating an anonymous array with the sorted values, but not actually assigning the sorted values back into @$outputRef.

-- Mike

--
just,my${.02}

Replies are listed 'Best First'.
Re^2: Why didn't this sort?
by tadman (Prior) on Jul 15, 2002 at 23:39 UTC
    I know this is a minor thing, but it's probably best to make sure that you use the same reference instead of making a new one. If $ouputRef was pulled from a blessed object, for example, then this reassignment creates a new instance that isn't linked in.

    Assign back to the same reference just to be safe:
    @$outputRef = sort @$outputRef;
    These are "equivalent" in terms of functionality, but not in terms of effect. For an example of what I mean:
    my $foo = [ [ 4, 1, 6 ], [ 4, 1, 5 ] ]; my $foo_0 = $foo->[0]; my $foo_1 = $foo->[1]; $foo_0 = [ sort @$foo_0 ]; # $foo_0 is "detached" @$foo_1 = sort @$foo_1; # Goes back into $foo->[1] use Data::Dumper; print Dumper($foo);