Ensure line items are in the right order before doing a groupby when rendering statements to pdf