weird sort behavior of Files.GetDirectory

I’m currently trying to improve the file browser in Kore, which uses the JSON RPC API.
That way found out that sorting with “method”: “path” of Files.GetDirectory doesn’t work as expected under some conditions.

With “media”: “files” it always works fine.
The API call

Code:
{"jsonrpc": "2.0", "id": 1, "method": "Files.GetDirectory", "params": {"directory": "/media/Musicdir/", "media": "files", "sort": {"order": "ascending", "method": "path", "ignorearticle": false}}}

returns the directory contents sorted by path.

However, the same call, just with “media”: “music” instead of “media”: “files”

Code:
{"jsonrpc": "2.0", "id": 1, "method": "Files.GetDirectory", "params": {"directory": "/media/Musicdir/", "media": "music", "sort": {"order": "ascending", "method": "path", "ignorearticle": false}}}

returns a directory listing, where files don’t seem to be sorted at all, just directories appear first.

With directories that contain only files that look like %tracknumber – %trackname the listing seems to be correct. but with directories that have different filenames the result seems to be random.

Is this a Bug or am I doing something wrong here?