Re: Sorting

On Mon, 2005-08-15 at 11:05 +0100, Steve Harris wrote:
> 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.

Where do you see that? I see

"If the ordering condition is a named variable, RDF Literals are
compared with the "<" operator (see below) where possible."
 -- http://www.w3.org/2001/sw/DataAccess/rq23/#solutionsResults
 v1.464 of 2005/08/10 15:51:50
 also in http://www.w3.org/TR/2005/WD-rdf-sparql-query-20050721/

and < is defined in the table below...

A <B numeric numeric op:numeric-less-than(A, B) xs:boolean



> 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
-- 
Dan Connolly, W3C http://www.w3.org/People/Connolly/
D3C2 887B 0F92 6005 C541  0875 0F91 96DE 6E52 C29E

Received on Monday, 15 August 2005 13:29:46 UTC