Refined the sorting of rstate revision to step correctly