B
B
Banan442020-05-13 09:54:17
JavaScript
Banan44, 2020-05-13 09:54:17

Sort array based on some string (Search in array)?

const search = "яблоко"
const array = ["Яблако",  "Яблоко", "Яблко", "Груша"]
// Какой-то код
// arraySearch - ["Яблоко", "Яблако", "Яблко"]

We need the simplest way to get an array: ["Apple", "Apple", "Apple"]
That is, some search results should be obtained (The most similar string at index 0, a little worse in the search - 1, then 2, etc.)
Texts can consist of several words

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2020-05-13
@Banan44

You need to use Levenshtein distance .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question