The answer is this:
<?php $_items = $this->getInvoice()->getAllItems() ?>
<?php $_sortedItems = array(); ?>
<?php foreach ($_items as $_item) : ?>
<?php $_sortedItems[$_item->getName()] = $_item; //getName() was the key! ?>
<?php endforeach;?>
<?php ksort($_sortedItems);?>
<?php $i=0;foreach ($_sortedItems as $_item):?>
<?php if ($_item->getOrderItem()->getParentItem()) continue; else $_i++; ?>
<?php //if ($_item->getParentItem()) continue; else $i++;?>
<tbody class="<?php echo $i%2?'even':'odd' ?>">
<?php echo $this->getItemHtml($_item) ?>
<?php echo $this->getItemExtraInfoHtml($_item->getOrderItem()) ?>
</tbody>
<?php endforeach; ?>
Sorting by SKU was a problem as configurable products have a different SKU type. So I simplified it and sorted it by Name. Now all items are listed, and listed alphabetically. This sorts the invoice in adminhtml
Also for the actual print side of things in invoice.php use:
$items = $invoice->getAllItems() ; // Gets items --- need to sort them first!
$_sortedItems = array(); // build array, inserts order items into array and sort
foreach ($items as $item) :
$_sortedItems[$item->getName()] = $item;
endforeach;
ksort($_sortedItems);
foreach ($_sortedItems as $item) { //pass sorted items back one at a time in alpha' order
if ($item->getOrderItem()->getParentItem()) {
continue;
in place of
foreach ($invoice->getAllItems() as $item){
if ($item->getOrderItem()->getParentItem()) {
continue;