anyway/backend/src/utils/take_most_important.py
Helldragon67 2810d93f98
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 1m56s
Run linting on the backend code / Build (pull_request) Failing after 25s
Run testing on the backend code / Build (pull_request) Failing after 1m9s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 15s
migrated tests
2024-11-18 16:52:01 +01:00

17 lines
619 B
Python

from ..structs.landmark import Landmark
def take_most_important(landmarks: list[Landmark], n_important) -> list[Landmark]:
"""
Given a list of landmarks, return the n_important most important landmarks
Parameters:
landmarks: list[Landmark] - list of landmarks
n_important: int - number of most important landmarks to return
Returns:
list[Landmark] - list of the n_important most important landmarks
"""
# Sort landmarks by attractiveness (descending)
sorted_landmarks = sorted(landmarks, key=lambda x: x.attractiveness, reverse=True)
return sorted_landmarks[:n_important]