array:sort, array:sort-by, and docs access

Saturday, 23 August 2025 · 3 messages
BD
Bridger Dyson-Smith23 Aug 2025 02:34 #
Dear Christian and BaseX friends, I hope this email finds you well! I had a question about function signatures:
it would seem that there's a typo/issue with the signature (and final
example) for array:sort[1,2]. Shouldn't the signature for array:sort read:
array:sort(
  $array        as array(*),
  $collation   as xs:string?                                      :=
fn:default-collation(),
  $key           as fn(item()*) as xs:anyAtomicType* := fn:data#1
) as item()*
(cribbed from the qt4cg.org specs[3])? Unless I'm misreading the
signature... in which case, excuse me!
Additionally, the current signature for array:sort seems to be in approximate alignment with array:sort-by, which is missing from our lovely BaseX docs' array page. To further my confusion, it looks like the examples from the qt4cg.org array:sort-by[4] signature work generally in my BaseX 12.0. Could that be added, or is the function still waiting in the BaseX wings? :) Best wishes, Bridger [1] https://docs.basex.org/main/Array_Functions#array:sort [2] the example `array:sort( [ 1, 2, 3 ], keys := fn($n) { -$n })` throws an error in BaseX 12.0: [XPST0017] array:sort(array[,collation,key]): Unknown keyword: keys. I'll update the example if I may please have access, otherwise, change `keys` to `key`, please. [3] https://qt4cg.org/specifications/xpath-functions-40/Overview.html#func-array-sort [4] https://qt4cg.org/specifications/xpath-functions-40/Overview.html#func-array-sort-by
CG
Christian Grün23 Aug 2025 08:52 #
Dear Bridger, Thanks for your observations. You are completely right, the documentation needs to be updated. The W3 sort function were revised multiple times in the recent past, which is why there are even some pending inconsistencies in the current spec. I will be offline for a while, and I will take care of it once I am back. Best, Christian
Quoted text · Bridger Dyson-Smith · 22 lines
Von: Bridger Dyson-Smith via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Samstag, August 23, 2025 2:34:49 AM An: BaseX <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] array:sort, array:sort-by, and docs access Dear Christian and BaseX friends, I hope this email finds you well! I had a question about function signatures: it would seem that there's a typo/issue with the signature (and final example) for array:sort[1,2]. Shouldn't the signature for array:sort read: array:sort( $array as array(*), $collation as xs:string? := fn:default-collation(), $key as fn(item()*) as xs:anyAtomicType* := fn:data#1 ) as item()* (cribbed from the qt4cg.org<http://qt4cg.org> specs[3])? Unless I'm misreading the signature... in which case, excuse me! Additionally, the current signature for array:sort seems to be in approximate alignment with array:sort-by, which is missing from our lovely BaseX docs' array page. To further my confusion, it looks like the examples from the qt4cg.org<http://qt4cg.org> array:sort-by[4] signature work generally in my BaseX 12.0. Could that be added, or is the function still waiting in the BaseX wings? :) Best wishes, Bridger [1] https://docs.basex.org/main/Array_Functions#array:sort [2] the example `array:sort( [ 1, 2, 3 ], keys := fn($n) { -$n })` throws an error in BaseX 12.0: [XPST0017] array:sort(array[,collation,key]): Unknown keyword: keys. I'll update the example if I may please have access, otherwise, change `keys` to `key`, please. [3] https://qt4cg.org/specifications/xpath-functions-40/Overview.html#func-array-sort [4] https://qt4cg.org/specifications/xpath-functions-40/Overview.html#func-array-sort-by
BD
Bridger Dyson-Smith23 Aug 2025 20:42 #
Christian -
Quoted text · Christian Grün · 9 lines
On Sat, Aug 23, 2025 at 2:52 AM Christian Grün <cg at basex.org> wrote: > Dear Bridger, > > Thanks for your observations. You are completely right, the documentation > needs to be updated. The W3 sort function were revised multiple times in > the recent past, which is why there are even some pending inconsistencies > in the current spec. > >
Enjoy your time away!
Quoted text · Christian Grün · 6 lines
> I will be offline for a while, and I will take care of it once I am back. > > Best, > Christian > >
Cheers, Bridger
Quoted text · Christian Grün · 48 lines
> ------------------------------ > *Von:* Bridger Dyson-Smith via BaseX-Talk < > basex-talk at mailman.uni-konstanz.de> > *Gesendet:* Samstag, August 23, 2025 2:34:49 AM > *An:* BaseX <basex-talk at mailman.uni-konstanz.de> > *Betreff:* [basex-talk] array:sort, array:sort-by, and docs access > > Dear Christian and BaseX friends, > I hope this email finds you well! I had a question about function > signatures: > > it would seem that there's a typo/issue with the signature (and final > example) for array:sort[1,2]. Shouldn't the signature for array:sort read: > array:sort( > $array as array(*), > $collation as xs:string? := > fn:default-collation(), > $key as fn(item()*) as xs:anyAtomicType* := fn:data#1 > ) as item()* > (cribbed from the qt4cg.org specs[3])? Unless I'm misreading the > signature... in which case, excuse me! > > Additionally, the current signature for array:sort seems to be in > approximate alignment with array:sort-by, which is missing from our lovely > BaseX docs' array page. To further my confusion, it looks like the examples > from the qt4cg.org array:sort-by[4] signature work generally in my BaseX > 12.0. Could that be added, or is the function still waiting in the BaseX > wings? :) > > Best wishes, > Bridger > > [1] https://docs.basex.org/main/Array_Functions#array:sort > > [2] the example `array:sort( [ 1, 2, 3 ], keys := fn($n) { -$n })` throws > an error in BaseX 12.0: > [XPST0017] array:sort(array[,collation,key]): Unknown keyword: keys. > I'll update the example if I may please have access, otherwise, change > `keys` to `key`, please. > > [3] > https://qt4cg.org/specifications/xpath-functions-40/Overview.html#func-array-sort > > [4] > https://qt4cg.org/specifications/xpath-functions-40/Overview.html#func-array-sort-by > > >

⚡Generated with XQuery