http://qs321.pair.com?node_id=1114752


in reply to How can I access object data in a user defined sort cmp function?

You can create a closure for the object:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my $self = { hash_ref => { item1 => 12, item2 => 9, }, }; print Dumper(sort_hash_ref_keys_by_value($self)); sub sort_hash_ref_keys_by_value { my $self = shift; my $by_value = sub { $self->{hash_ref}->{$a} <=> $self->{hash_ref}->{$b} }; return sort $by_value keys %{ $self->{hash_ref} }; }
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ