my @order; for my $key (keys %HoA) { splice(@order, ($key eq 'Foo') ? 0 : @order, (), $key); }