short answer:
before using pack_padded_sequence you need to sort the inputs by length and pass that to the function.
sorting will return the permutation index and you can use that to permute your output
x = ['aaa', 'bbbb', 'cc']
lengths = torch.tensor([3,  4, 2])
lengths_permuted, perm_index = length.sort(0, descending=True)
x_permuted = x[perm_index]
x_packed = torch.nn.utils.pack_padded_sequence(x_permuted, lengths)
lstm_out_packed, h = LSTM(x_packed, h)
output_permuted = output[perm_index]

longer answer:
when using packed sequence the strings are rearranged by length
then they are stacked vertically
in your example it will be
Jemaldinov
Griffiths
Naifeh
each iteration it will process the i’th column across all rows if exists and pass it to the next rnn cell
that’s why it seems to you like the letters got scrambled.

check this blog for a good example of how to use padded seq:
https://towardsdatascience.com/taming-lstms-variable-sized-mini-batches-and-why-pytorch-is-good-for-your-health-61d35642972e 2

check this repo for understanding the inside of a packed seq:
https://github.com/sgrvinod/a-PyTorch-Tutorial-to-Sequence-Labeling#language-models 1