brianreavis / sifter.js

A library for textually searching arrays and hashes of objects by property (or multiple properties). Designed specifically for autocomplete.
1.09k stars 125 forks source link

Allow to sort on nested properties #26

Closed noirbizarre closed 8 years ago

noirbizarre commented 9 years ago

Hi!

I'm lacking sorting on nesting property (and potentialy search on).

Imagine the following objects:

let data = [
    {name: 'John Doe', metrics: {a: 15, b:17}},
    {name: 'Jane Doe', metrics: {a: 18, b:2}}
];

I want to be able to write:

let s = new Sifter(data).search('', {
    fields: [],
    sort: [{field: 'metrics.a', direction: 'asc'}]
});

Is there a way to do this today ?