You are given a long-format DataFrame df with three columns: date, product, and sales. Some (date, product) pairs may appear more than once.
Write a function solution(df) that performs two transformations:
Reshape the data into a wide format where each distinct date is a row and each distinct product is a column, with the cell values being the total sales for that (date, product) combination. Any missing (date, product) combination should be filled with 0.
Reshape the wide table back into long format so the result again has the columns date, product, and sales.
Return the final long-format DataFrame. The rows must be sorted by date then product (ascending), and the index must be reset to 0..n-1.