[FIX] This sorting is necessary since aggregate does not preserve (it sorts the data by key) order while duplicate does