Instantsearch sortBy error

Hi, I am getting the below error using the sortBy widget in instantsearch. I am using plain JavaScript. I would appreciate any feedback. Thanks!

Uncaught TypeError: instantsearch.widgets.sortBy is not a function

Code snippet:
container: ‘#sort-by-container’,
items: [
{ value: ‘stage-products’, label: ‘Most relevant’ },
{ label: ‘Price (asc)’, value: ‘instant_search_price_asc’ },
{ value: ‘products_price_desc’, label: ‘Price (desc)’ }


The widget was not called sortBy, but sortBySelector in v2 which you are using

The docs for v2 are here:

Here’s your code fixed: :

PS: you probably want to update to InstantSearch v4 for all the latest features, a migration guide is here:

Thanks for the solution in v2! I ended up migrating the code to v4.

1 Like