Re-sorting and summing up