0

How can I use _.sortBy with _.template to sort the suggestions in typeahead? I have tried a lot of different things, is it even possible?

1

I'm far from being an expert (or even good) in JavaScript, but I think you could go to the search() function inside scripts.js and call _.sortBy on data here:

// call typeahead's callback with search results (i.e., places)
cb(data); 

So you would get something like this if you wanted to sort by postal_code:

// call typeahead's callback with search results (i.e., places)
cb(_.sortBy(data, 'postal_code'));

If this solves your problem, please click the check mark to accept the answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .