in reply to How can I access object data in a user defined sort cmp function?
I hope that is helpful :)#/usr/bin/perl use warnings; use strict; use Data::Debug; my @things; push @things, Thing->new() for (1..10); debug @things; my @sorted = sort { $a->key->{'other'} <=> $b->key->{'other'} } @thing +s; debug @sorted; package Thing; sub new { return bless { key => { other => int(rand(42))} }, 'Thing'; +} sub key { return shift->{'key'}; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can I access object data in a user defined sort cmp function?
by tkguifan (Scribe) on Jan 29, 2015 at 19:37 UTC |