У меня есть словарь в котором координаты различных мест:
STORES: Tuple[dict, ...] = (
{'title': 'Besh Yogʻoch Savdo',
'lons': '41.304679',
'lats': '69.247453',
'address': 'Oziq-ovqat'},
{'title': 'Бахт: колбасы и деликатесы',
'lons': '41.293083',
'lats': '69.212116',
'address': 'Oziq-ovqat'},
{'title': 'Eco - mini market🛒',
'lons': '41.305242',
'lats': '69.235547',
'address': 'Oziq-ovqat'},
)
И обработчик принятого местоположения от пользователя телеграм:
def uz_shop_view(message: telebot.types.Message):
if message.location is not None:
lon: float = message.location.longitude
lat: float = message.location.latitude
distance: List[...] = []
for loc in STORES:
result: float = geodesic(
(loc['lons'], loc['lats']), (lon, lat)).meters
distance.append(result)
index = distance.index(min(distance))
bot.send_venue(message.chat.id,
STORES[index]['lons'],
STORES[index]['lats'],
STORES[index]['title'],
STORES[index]['address'])
elif message.location is None:
bot.reply_to(message, "Отправь местоположение!")
И вот вопрос:
Как сделать так чтобы тг бот после получения геопозиции отправил в ответ все места списком из словаря отсортировав его в порядке возрастания смотря на расстояние от него?
библиотека: telebot, geopy