I agree, you could sort first by absolute acceleration, then by velocity, then by position. I took the liberty of making an assumption that the min would be unique. I could be wrong. But even so, there is a similar solution.