Embed ordering

added the test case from #176 

I can reproduce the issue on Sqlite, but not MongoDB. Can someone try on Postgres/MySQL? If the error occurs there than the issue is probably in the JSON serialization/de-serialization