use reordering algorithm of phpcr-utils to fix this issue (and drop a hairy algo from the codebase)