/**
 * This function takes a list of star details and an index indicating the position of the distance value.
 * It returns a tuple with the details of the star that is closest to Earth based on the distance value.
 *
 * @param stars A list containing details of various stars.
 * @param distanceIndex The index indicating the position of the distance value in each star's details.
 * @return A tuple with the details of the closest star.
 */
fun findClosestStar(stars: List<List<Any>>, distanceIndex: Int): List<Any>? {

    var closestStar: List<Any>? = null
    var closestDistance = Double.POSITIVE_INFINITY

    for (star in stars) {
        val distance = star[distanceIndex] as Double
        if (distance < closestDistance) {
            closestDistance = distance
            closestStar = star
        }
    }

    return closestStar
}
/**
 * This function takes a list of star details and an index indicating the position of the distance value.
 * It returns a tuple with the details of the star that is closest to Earth based on the distance value.
 *
 * @param stars A list containing details of various stars.
 * @param distanceIndex The index indicating the position of the distance value in each star's details.
 * @return A tuple with the details of the closest star.
 */
fun findClosestStar(stars: List<List<Any>>, distanceIndex: Int): List<Any>? {
/**
 * This function takes a list of star details and an index indicating the position of the distance value.
 * It returns a tuple with the details of the star that is closest to Earth based on the distance value.
 *
 * @param stars A list containing details of various stars.
 * @param distanceIndex The index indicating the position of the distance value in each star's details.
 * @return A tuple with the details of the closest star.
 */
fun findClosestStar(stars: List<List<Any>>, distanceIndex: Int): List<Any>? {

    var closestStar: List<Any>? = null
    var closestDistance = Double.POSITIVE_INFINITY

    for (star in stars) {
        val distance = star[distanceIndex] as Double
        if (distance < closestDistance) {
            closestDistance = distance
            closestStar = star
        }
    }

    return closestStar
}