Since you're talking "node-sets" I assume you're using XPath 1.0 - you really ought to say so. A node-set in XPath 1.0 is a set of nodes with no particular order; however XSLT always processes the nodes in a node-set in document order, and this has established a precedent which as far as I know all XPath 1.0 processors follow whether they are being used in XSLT or not. So expressions that return node-sets are likely to return the nodes in document order, which is the effect you are observing.
XPath 2.0 introduces sequences, which allows you to return nodes in any order of your own choosing.