I believe relocations are sorted by offset, so this code is redundant.
We have the same assumption for other targets.
GNU as for RISC-V does actually produce out-of-order relocations so lld cannot assume they are always sorted by offset. This was previously discussed at:
Some parts of the code in lld like OffsetGetter::get() for merging .eh_frame also depends on the relocations being sorted by offset, so sorting here isn't simply a performance optimization to do binary search.