code: protected function buildInvoiceList(IM\InvoiceSubjectInterface $subject)
      {
          $invoices = $subject->getInvoices(true)->toArray();
  
          usort($invoices, function (IM\InvoiceInterface $a, IM\InvoiceInterface $b) {
              return $a->getCreatedAt()->getTimestamp() - $b->getCreatedAt()->getTimestamp();
          });
  
          return array_map(function (IM\InvoiceInterface $invoice) {
              return [
                  'invoice' => $invoice,
                  'total'   => $invoice->getGrandTotal(),
              ];
          }, $invoices);
      }
docs: Builds the sale invoices list.
  
  @param IM\InvoiceSubjectInterface $subject
  
  @return array