If your data is indeed stored in a hash you could do something like:
substituding the print statement with whatever is needed for your larger application. Note that my example works if two keys have the same dependency. And you'll get a warning about uninitialzed value when it tries to print $sortme{1};#!/usr/bin/perl -w use strict; my (%sortme, $k); %sortme = ( 1 => undef, 2 => 4, 3 => 5, 4 => 3, 5 => 1, 6 => 3 ); foreach $k ( sort { return -1 if !defined $sortme{$a}; return 1 if !defined $sortme{$b}; $sortme{$a} <=> $sortme{$b}; } keys %sortme ) { print "$k -> $sortme{$k}\n"; }
In reply to Re: Sorting by association, a tail of dependency resolving gone nowhere
by mikeraz
in thread Sorting by association, a tail of dependency resolving gone nowhere
by jcpunk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |