You need to play with JSON1. `json_each` is a table-valued function which generates rows on the fly, and one of the column, for arrays, is the index into the array. And I simply order on that. Oops, sorry, I thought you meant my technique :) Regarding the other technique, id=13 is a boolean expression, and true sorts after false, thus the `DESC` to reverse that, so it's like sorting these tupples (1,0,...), (0,1,0,...), etc... That's pretty twisted :) In an interesting way I mean!