I am developing a Visualforce Page which is for configuring some User Settings. The Requirement is that when the page is saved it should redirect to where the user is able to edit the Settings of the next alphabetical user.
For example lets say all the users in the System are ordered alphabetically by
- Kent Brockman
- Timothy Lovejoy
- Maud Flanders
- Frank Grimes
- Troy McClure
- Homer Simpson
- Marge Simpson
- Moe Szyslak
If I am editing "Frank Grimes" when I save I should be redirected to "Troy McClure".
If I edit "Moe Szyslak" I should be redirected back to "Kent Brockman"
I know it would be possible to just query every user ordered by LastName and loop through until I find the user after the current one, but this could potentially exhaust my governor limits.
What I am wondering is ther a more efficent way to query the next alphabetical user?