when I sort on number by doing this sort by (number), output is incorrect because 44 comes after 333 and I think it’s because 4 is after 3, but can I’ve 44 comes before 333?
the result is correct, because without any additional type information (e.g. from a schema), XQuery will sort the values as strings (where “333” < “44”). If you want numerical sort, you have to give type information, either in the Tamino schema or in the query, e.g. declare namespace xs = “XML Schema” let $doc:=
001
002
44
333
for $i in $doc/document sort by (xs:integer(number)) return $i
The problem is that my field number is and must be of a type string because some contracts (number is for this) can have a number like this : A-1, ZZ-33,…
Maybe it’s impossible with tamino to sort correctly because I can’t use xs:integer for the field with alphabetical values.