http://qs1969.pair.com?node_id=880053


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;