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 Answer
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.