in reply to sort in arbitrary order with subroutine, syntax error

The sort docu tell you that can either use sort SUBNAME LIST or sort BLOCK LIST, and you do neither => syntax error.

Just use the BLOCK form, and everything will work: sort {by_seq([qw(five nine one seven three)])} keys %h