'Indexed sorting of multiple values

Given these lines of code:

let order = cts.indexOrder(cts.elementReference(fn.QName('','order')))
cts.search(cts.jsonPropertyValueQuery('order','*', ['wildcarded'] ),order)

I get this result:

{"order":["a", "m"]}
{"order":"a"}
{"order":["a", "x"]}
{"order":"j"}
{"order":["j", "k", "l"]}
{"order":["j", "k"]}
{"order":["j", "k", "m"]}
{"order":"m"}
{"order":["m", "z"]}

Shouldn't ["a"] sort before ["a","m"], and ["j","k"] precede ["j","k","l"]?

It seems like there is some kind of ordering, but it's not precise in this way, and I'd like to understand the rules, as we have exactly this situation in a project I'm working on.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source