query-1f1b0c47dfbb1ae8f158ac651a31a76d
10:59, 4 February 2018 (UTC)) talk (Prtksxna Sorry if I misunderstood the question. Almost, but there is still something that is not quite right: if two items have catalogue code F21 and F21b, we should make sure that F21 b comes after F21, which this query does not do. Actually I have just found a way to do it, but it looks awful:Query 11:42, 4 February 2018 (UTC)) talk (ZoloSo maybe there is a cleaner way to convert all those letters into numbers ?--Great ! This way, this way it uses a secondary sortkey with the intended result: 12:09, 4 February 2018 (UTC) Jura--- Maybe using ORDER BY ?catnum ?optionalcatletter 12:05, 4 February 2018 (UTC)) talk (Edgars2007 function, but after a quick googling it doesn't seem to be available for SPARQL. --charOne "solution" would be adding natural sorting in Listeria bot code. Other solution would be some kind of
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?item ?catcode WHERE {
?item p:P528 [ pq:P972 wd:Q17280421 ; ps:P528 ?catcode].
BIND( xsd:integer(REPLACE(?catcode, "[a-zA-Z]", "")) AS ?catnum)
BIND(REPLACE(?catcode, "F[0-9]*", "") AS ?catletter)
}
ORDER BY ?catnum ?catletter