SORT option not work
See original GitHub issueDEMO as follows:
(async () => {
const si = require('../../')
const cars = [
{
_id: 0,
make: 'Volvo',
colour: 'Black',
year: 2011,
price: 82580,
model: 'XC90',
drivetrain: 'Hybrid'
},
{
_id: 1,
make: 'Tesla',
colour: 'White',
year: 2012,
price: 36693,
model: 'S',
drivetrain: 'Electric'
},
{
_id: 2,
make: 'Volvo',
colour: 'Blue',
year: 2005,
price: 36130,
model: 'XC60',
drivetrain: 'Hybrid'
},
{
_id: 3,
make: 'Volvo',
colour: 'Black',
year: 2016,
price: 42522,
model: 'XC90',
drivetrain: 'Diesel'
},
{
_id: 4,
make: 'Volvo',
colour: 'Red',
year: 2010,
price: 60084,
model: 'XC60',
drivetrain: 'Petrol'
},
{
_id: 5,
make: 'BMW',
colour: 'Black',
year: 2013,
price: 88503,
model: '3-series',
drivetrain: 'Diesel'
},
{
_id: 6,
make: 'Volvo',
colour: 'Silver',
year: 2011,
price: 73297,
model: 'XC60',
drivetrain: 'Petrol'
},
{
_id: 7,
make: 'Volvo',
colour: 'Silver',
year: 2009,
price: 55938,
model: 'XC90',
drivetrain: 'Petrol'
},
{
_id: 8,
make: 'Volvo',
colour: 'Silver',
year: 2010,
price: 92375,
model: 'XC60',
drivetrain: 'Petrol'
},
{
_id: 9,
make: 'Tesla',
colour: 'Red',
year: 2008,
price: 74017,
model: 'X',
drivetrain: 'Electric'
},
{
_id: 10,
make: 'Tesla',
colour: 'Red',
year: 2008,
price: 74017,
model: 'X',
drivetrain: 'Diesel-2'
}
]
const print = txt => console.log(JSON.stringify(txt, null, 2))
const db = await si({ name: 'QUERY' })
await db.PUT(cars)
console.log('\nSEARCH and SORT ->')
await db.QUERY({
SEARCH: ['make:Volvo', 'drivetrain:Petrol']
}, {
SORT: {
TYPE: 'NUMERIC',
DIRECTION: 'DESCENDING',
FIELD: 'price',
},
}).then(print)
})()
When I did not pass in SORT, the result is as follows:
SEARCH and SORT ->
{
"RESULT": [
{
"_id": "4",
"_match": [
"make:volvo#1.00",
"drivetrain:petrol#1.00"
],
"_score": 2.2
},
{
"_id": "6",
"_match": [
"make:volvo#1.00",
"drivetrain:petrol#1.00"
],
"_score": 2.2
},
{
"_id": "7",
"_match": [
"make:volvo#1.00",
"drivetrain:petrol#1.00"
],
"_score": 2.2
},
{
"_id": "8",
"_match": [
"make:volvo#1.00",
"drivetrain:petrol#1.00"
],
"_score": 2.2
}
],
"RESULT_LENGTH": 4
}
But when I pass in, the result is still the same:
SEARCH and SORT ->
{
"RESULT": [
{
"_id": "4",
"_match": [
"make:volvo#1.00",
"drivetrain:petrol#1.00"
],
"_score": 2.2
},
{
"_id": "6",
"_match": [
"make:volvo#1.00",
"drivetrain:petrol#1.00"
],
"_score": 2.2
},
{
"_id": "7",
"_match": [
"make:volvo#1.00",
"drivetrain:petrol#1.00"
],
"_score": 2.2
},
{
"_id": "8",
"_match": [
"make:volvo#1.00",
"drivetrain:petrol#1.00"
],
"_score": 2.2
}
],
"RESULT_LENGTH": 4
}
I don’t know what to do. Please help.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Sort not working the way its supposed to.
If it looks like the data did not sort properly, refer to the following list of possible solutions: • Make sure no hidden...
Read more >Why Won't My Spreadsheet Sort?
If verifying your data and your worksheet format doesn't resolve your sorting problems, shut down Excel and restart your computer to see if...
Read more >My excel spreadsheet won't sort/alphabetize properly
The most common reason for data not sorting correctly is due to the leading space ahead of the text. Many people ...
Read more >Why are the sort and filter options greyed out?
Sometimes Excel's sorting and filtering options become grayed-out and unusable for no apparent reason. This article explains how to fix the problem.
Read more >[Fix:] Sort and Filter Not Working in Excel
In this article, I'll show 8 issues for not working with sort and filter in Excel along with their solution.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@fergiemcdowall It seems the above API has changed and the docs are not updated. Reading the tests it seems you can now only sort based on what you specified in SCORE, is that correct?
Yes- its not totally intuitive- this is probably something that could be explained better in the docs