use Sort::Key; sub mykeysort { ikeysort { /foo(\d+)\.tla/; $1 } @_ }