This did not work for me. I modified the code and the following did work:
In your packing slip template, find the line:
{% for line_item in line_items_in_shipment %}
and replace it with
{% assign lineitems = line_items_in_shipment | sort: “title” %}
{% for line_item in lineitems %}