Sorting

I now have a crude implementation of ORDER BY, but I'm finding the
arbitrary ordering specified in the language spec. a bit inconvientient.

For example, if you have:

	SELECT ?v
	WHERE { ?x rdf:value ?v .
	        FILTER(datatype(?v) = xsd:decimal) }
	ORDER BY DESC(?v)
	LIMIT 10

you might hope to get the highest v's back, but to my reading of the
spec you will get back the one with the most 9s at the start, or something
similar, as the ordering is lexical.

One way to get that might be allow casting in the ORDER BY constraint
(ORDER BY DESC(xsd:decimal(?v)), but that adds complexity, and I'm not a
fan of that. Another would be to relax the constraints on what the order
must be (eg, to just ensuring that its consistant), to allow the
implementations to do something sensible.

The current spec. seems to lead you to something which is quite
complicated to implement, but the complexity doesn't add much capability.

- Steve

Received on Monday, 15 August 2005 10:05:53 UTC