padolsey / relevancy.js

:bar_chart: Sort/Weigh strings by relevance
286 stars 8 forks source link

Searching objects #1

Closed theluk closed 12 years ago

theluk commented 12 years ago

Hi there.

is there a way to search in objects and return them? or is this on your list already?

var items = [{ title:"London"}, {title:"Munich"}];
Sorter.sort(items, "Lon", "title");
//or
Sorter.sort(items, "Lon", function(obj) { return obj.title });
padolsey commented 12 years ago

This is now possible with the following calling pattern:

var items = [{ title:"London"}, {title:"Munich"}];
Sorter.sort(items, "Lon", function(obj, calc) { return calc(obj.title) });