jsdelivr/api — pull request #41 by gavinhungry (2014-06-06 20:59:41+00:00)
Title: Sort results by Levenshtein distance from the requested name

I noticed that searching for `name=jquery*` on CDNJS did not return jQuery as the top result, or even in the top 100 results!
http://api.jsdelivr.com/v1/cdnjs/libraries?name=jquery*&limit=100&fields=name

This sorts the results (before a limit is imposed) based on the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) between the package name and the requested name (it would probably muss up a bit if one was to go nuts with the minimatch syntax).

Before (`name=jquery*&limit=4&fields=name`):

[
{
"name": "jQuery-Geolocation"
},
{
"name": "jQuery-Validation-Engine"
},
{
"name": "jQuery-slimScroll"
},
{
"name": "jQuery.dotdotdot"
}
]

After:

[
{
"name": "jquery"
},
{
"name": "jqueryui"
},
{
"name": "jquery-te"
},
{
"name": "jquery.pep"
}
]
After: