sort before splice