Pseudo Code optimization
I think it would be perfectly reasonable and normal to present the pseudocode as is, and to mention in the accompanying text that if you sort $R$ in advance, you can implement this algorithm in $O(m \log m)$ time.  I think it's pretty clear how to implement the selection step, and you don't need to write out all the indices to explain.