The way the report is generated depends on the 'Reporting (Print invoice item sort by item description)' setting, which affects how items are sorted on the printed invoice. To fix this:
Go to Housekeeping, Setup, General Setup, Stock Valuation.
Under the Reporting section, Untick Print Invoice Item Sort by Item Desp.
Preview the Sales Order again.
