In Dijkstra's algorithm, when we are retrieving elements from the processing queue (I mean, the queue where we append the vertexes of the graph, and we take elements from there), we're supposed to store it in a priority queue or whatever, so that the next vertex to be processed is the one with less distance.
Why is this? I mean, I thought that the vertexes in Dijkstra could be visited in any order (as long as you follow the connection path).