SPARQL idioms

Sorting literals with language tags in an implementation-independent way

The SPARQL spec only defines an ordering for plain literals. Implementations may impose an order in addition to this, but you can't rely on it.

The correct clause for doing this is:

        ORDER BY str(?literal) fn:lower-case(LANG(?literal)) LANG(?literal)

Note that this depends on fn:lower-case to treat "x"@en and "x"@EN the same.