Order and search algorithm