sort before re-assignments