Let's say we have an array of objects called result
:
{ "name": "C:\\file.json", "relevance": 0.5 }
{ "name": "C:\\folder", "relevance": 0.5454545454545454 }
{ "name": "C:\\file_1.txt", "relevance": 0.1 }
How do we sort it by relevance
key and push the name
values into a new array in the sorted order, so that we get the following arr
:
["C:\\folder", "C:\\file.json", "C:\\file_1.txt"]
UPDATE
It's not a duplicate! I don't know why people in js
threads always marking answers as duplicate, even when they very much aren't