WordPress meta_query / Sort array in php for autocomplete

I have an autocomplete plugin in my wordpress website.
My results are shown in alphabetical order like that (LIMIT 10)
For this query : ‘Foo’ it shows me that :

A...Foo..
A.. Foo...
A..... Foo
A. Foo....
A.. Foo...
A.... Foo.
B.... Foo.
B. Foo....
B.... Foo.
B. Foo....
B.... Foo.

This is my PHP array

Read More
$suggestions[] = apply_filters( 'yith_wcas_suggestion', array(
                        'id'    => $product->id,
                        'value' => strip_tags($product->get_title()),
                        'url'   => $product->get_permalink()
                    ), $product );

I want to have in my suggestion array the similar string to “foo product”(which is actually 43st in my php array) and not the other product who contain the word “Foo”.

How can I sort $suggestions to show the closest value to ‘FOO’ in first result ?

Thank you very much.

Related posts