Fix crash in sorting of nearby pages

IllegalArgumentException: Comparison method violates its general contract

bug: 72066
Change-Id: Ife50b225797cf0a471ac29a6db1d676316a7a860