The following two examples show the problem with common search interfaces when there are multiple pages.
« previous 1 2 … 118 119 120 121 122 123 124 125 126 … 129 130 next »
What happens if I want page 50? I invite you to try it.
What if I want page 300? Again I invite you to try.
A solution using simple binary search
Use a classic binary search. Always round down.
< 1 ... 49,50,51 ... 100 >
You click on the ellipsis (or the nearest number) between the limits you are interested in and you see a new selection. So, suppose I want page 80. I click on the right-most ellipsis and get:
< 51 ... 74,75,76 ... 100 >
< 76 ... 87,88,89 ... 100 >
< 76 ... 80,81,82 ... 87 >
Then click on 80.
The whole thing takes 4 clicks. It also scales very well (1 million pages would require a maximum of 20 clicks to reach any single page). It can easily be made more intuitive by also allowing clicking on the nearest number to your destination.
Is there a technical (or other good) reason that web developers don't use a binary search as I showed? It is a classic algorithm and is easy to implement in a dozen lines of code.
Binary search works on sorted arrays. Binary search begins by comparing the middle element of the array with the target value. If the target value matches the middle element, its position in the array is returned. If the target value is less than the middle element, the search continues in the lower half of the array. If the target value is greater than the middle element, the search continues in the upper half of the array. By doing this, the algorithm eliminates the half in which the target value cannot lie in each iteration. https://en.wikipedia.org/wiki/Binary_search_algorithm