Vega-lite_Sort Facets

Hi everybody!

I’m creating notebook in Observable within Vega-lite.

I need to sort facets according to the field place from my dataset.
I’ve already added this instruction, but it works with faceting field only which is performance_id:


How to make it work with field place?

Hi Amidsi, take a look at the vegalite documentation for more information about how to sort: Sorting | Vega-Lite

It looks like something like this should work:

.sort({field: "place", order: "ascending"})
1 Like

Hi Duane! Thx, I’ve also tried to do smth like this, it change the order, but in a very weird way and now I’ve got at least what is problem there at least.
It puts places number 11 and 12 before 2, 3, 4 etc. coz they started from figure 1 I believe. What do you think one can do with it?
I added you as an editor to my notebook.
Thx in advance :pray:

This is because the place column is a string which will end up being sorted alphanumerically, rather than numerically. If you transform the place property to numbers then the sorting will be numeric. E.g.:

bv2= (await FileAttachment("bv_template.csv").csv()).map(d => ({...d, place:}))
1 Like