>>> import sakstig
>>> queryData = sakstig.QuerySet([
... {"key": "i23",
... "classification": "lastname1, firstname1 / apartment / Vienna / Alsergrund / thathouse / 1965"},
... {"key": "i3076",
... "classification": "lastname1, firstname1 / apartment / Vienna / Alsergrund / thathouse / 1978"},
... {"key": "i347",
... "classification": "lastname1, firstname1 / apartment / Vienna / Alsergrund / thathouse"},
... {"key": "i169",
... "classification": "lastname1, firstname1 / apartment / Vienna / Alsergrund / thathouse"},
... {"key": "i2929",
... "classification": "lastname1, firstname1 / apartment / Vienna / Alsergrund / thathouse"},
... {"key": "i1347",
... "classification": "lastname1, firstname1 / apartment / Vienna / 1999"
... }
... ])
>>>
>>> queryData.execute('sort($, slice(split(@.classification, "/"), [2, None])+[@.key]).*', compatibility=False)
{'key': 'i1347', 'classification': 'lastname1, firstname1 / apartment / Vienna / 1999'}
{'key': 'i169', 'classification': 'lastname1, firstname1 / apartment / Vienna / Alsergrund / thathouse'}
{'key': 'i2929', 'classification': 'lastname1, firstname1 / apartment / Vienna / Alsergrund / thathouse'}
{'key': 'i347', 'classification': 'lastname1, firstname1 / apartment / Vienna / Alsergrund / thathouse'}
{'key': 'i23', 'classification': 'lastname1, firstname1 / apartment / Vienna / Alsergrund / thathouse / 1965'}
{'key': 'i3076', 'classification': 'lastname1, firstname1 / apartment / Vienna / Alsergrund / thathouse / 1978'}
The key parameter to the sort function can now be a path, which is executed in the local context of the current row being sorted. It should return a single result, which the row will be sorted by.
Also, note that I turned off full compatibility with ObjectPath in the call above, which among other things slightly affects how .* works, which makes some stuff less confusing but does break compatibility, check the documentation for details.