Sort for final output