const towns = [
'Бердичев',
'Великая Чернетчина',
'Геническ',
'Гнездычев',
'Черкассы'
];
const query = 'че';
let result = towns
.map(town => ({
name: town,
index: town.toLowerCase().indexOf(query),
}))
.filter(town => town.index >= -1)
.sort((a, b) => a.index - b.index)
.map(town => town.name);