通过使用作为字符串出现的非负整数在 sparql 中按升序排列结果

Ascending order of results in sparql by using nonnegative integers that come as strings

我的三元组存储 (GraphDB) 中有 2000 多个资源,我想根据它们的 IRI 按升序排序,而 IRI 看起来像:

http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#3
...
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2345

在我的图表中,上述所有 IRI 都通过 "DE6:complex_Data_Type_has_Member" 连接到一个资源。为了获得上述所有 IRI,我执行以下操作:

PREFIX DE6: <http://DE6/DINEN61360#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?IRIs_to_Sort WHERE{
         ?Array a DE6:Data_Element;
         DE6:complex_Data_Type_has_Member ?IRIs_to_Sort .


} ORDER BY ?IRIs_to_Sort 

如果我只是使用 "ORDER BY ?IRIs_to_Sort" 解决方案序列修饰符,其中 https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#modOrderBy

然后我得到以下结果(只显示前十个结果):

http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#10
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#100
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1000
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1001
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1002
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1003
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1004
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1005
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1006
...
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1999
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#20
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#200
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2000
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2001
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2002
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2003
...

相反,我希望是这样的:

http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#1
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#3
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#4
...
http://TABLE/240b9f63-66b9-47f1-9e02-bfd03794bbd9#2099

我在这里错过了什么?

IRI 被视为 ORDER BY 的词法值,这意味着您的片段 ID 中的数字被视为文本,它们不会被单独考虑。

我认为对您有用的完整 ORDER BY,无论您的结果集包含一个或多个 IRI,每个 IRI 具有一个或多个片段 ID,但 仅当所有片段 ID是数字,将是--

ORDER BY ( xsd:string ( STRBEFORE ( STR ( ?IRIs_to_Sort ), "#" ) ) )
         ( xsd:long ( STRAFTER ( STR ( ?IRIs_to_Sort ), "#" ) ) ) 

如果您的 frag-ID 是数字和字母数字的混合体,事情就会变得更加复杂。