Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Sorting based on a specific order

by PeterPeiGuo (Hermit)
on Jan 02, 2011 at 06:27 UTC ( [id://880053] : note . print w/replies, xml ) Need Help??


in reply to Sorting based on a specific order

Here is one solution: use a hash to store the predetermined order - teacher's name as the key and the value could be an integer that determines the order.

Peter (Guo) Pei

Replies are listed 'Best First'.
Re^2: Sorting based on a specific order
by ikegami (Patriarch) on Jan 02, 2011 at 07:37 UTC
    my @order = ...; my %order = map { $order[$_] => $_ } 0..$#order; my @sorted = sort { $order{$a} <=> $order{$b} } @unsorted;