4umi.com/web/javascript/textlike

Test a text

Dynamic Javascript

An array of names is to be sorted by the nearest match to another name.

Other

That 's right: another word.

var name = 'Jakarta';
var names = [ 'Soenda Kelapa', 'Jayakarta', 'Nieuw Hoorn', 'Batavia', 'Djakarta', 'Jakarta U', 'Why Jakarta' ];

function comp(a,b){return 1;}

names.sort( comp );
alert( names );/**/

So far, so good.