@sorted = map {$_->[0]} map { $i=0; sort {$b->[1]<=>$a->[1]} map {[$i++,$_]} splice (@sim,0,9) } 0..8; print "\@index_ordered =(\n"; for(0..8) { print " " x 4, join(', ', splice (@sorted,0,9) ),"\n"; } print ");\n"; #### @index_ordered =( 0, 1, 3, 2, 4, 5, 7, 8, 6 1, 0, 3, 8, 2, 4, 7, 6, 5 2, 3, 8, 0, 1, 4, 7, 5, 6 3, 0, 1, 2, 8, 7, 6, 4, 5 4, 8, 7, 0, 1, 2, 6, 3, 5 5, 0, 7, 1, 2, 3, 6, 8, 4 6, 7, 8, 3, 4, 1, 2, 0, 5 7, 6, 8, 3, 4, 0, 1, 5, 2 8, 7, 6, 3, 4, 1, 2, 0, 5 );