Added ORDER BY to enforce share entry order

Sometimes MySQL decides to return the shares in the wrong order, but
some parts of the code seem to require the order to be known, at least
so that the parent shares come before the children shares.

This fix adds an ORDER BY clause to force the order by id.

This should reduce the probability of having randomly failing sharing tests, but doesn't seem to fix the main issue yet. This is a step forward.

Please review @schiesbn @icewind1991