I've recently noticed that on the Orders, Invoice, and Packing Slip pages in the admin, the product attributes seem to be in a random order.

Is there a way to adjust these pages so the attributes use the sort order specified in the Attributes Controller?

It's a problem for my client because her attributes are paired, and it's confusing to create the product when these attributes are out of order.

Example:

1 x Mommy Tags Bracelet
- Second Child Name: joe smith (+$7.50)
- Main Tag Birthdate: 08/19/03
- Main Tag Child Name: josephine smith
- Second Child Birthdate: 06/08/06

We would like to see these in order, like so:

1 x Mommy Tags Bracelet
- Main Tag Child Name: josephine smith
- Main Tag Birthdate: 08/19/03
- Second Child Name: joe smith (+$7.50)
- Second Child Birthdate: 06/08/06

I've looked at invoice.php and packingslip.php files, but am not sure how (or if) this is being sorted.

Any tips on how to make this change?

This is for a 1.2.7 site.

Code:
      if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) {
        for ($j=0, $k=sizeof($order->products[$i]['attributes']); $j<$k; $j++) {
          echo '<br><nobr><small>&nbsp;<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
          echo '</i></small></nobr>';
        }
      }
Thanks in advance for any advice or code!