Python - Pretty Brute Forceish but easy to understand
\nclass Solution:\n    def nearestValidPoint(self, x: int, y: int, points: List[List[int]]) -> int:\n        valid_pair = []                                    
```\nclass Solution:\n    def nearestValidPoint(self, x: int, y: int, points: List[List[int]]) -> int:\n        valid_pair = []                                        #Initializing an empty array\n        distance_holder = (9999,9999)                          #creating default values for distance holder    \n\n        \n        def __calculate_manhattan(x,y,x_point,y_point):        #helper function to calculate manhattan distance\n            return abs(x-x_point) + abs(y-y_point)\n            \n        for idx,pair in enumerate(points):                     #iterate through the points and keep index\n            x_point,y_point = pair                             #unpack pairs into x/y points\n            \n            if x==x_point or y==y_point:                       #checking if x or y equal points\n                distance = __calculate_manhattan(x,y,x_point,y_point)  #get manhattan distance\n                if distance <= distance_holder[1]:             #check if distance is less than what\'s currently in holder\n                    if distance == distance_holder[1]:         #check if distances are equal to each other\n                        distance_holder = (min(distance_holder[0],idx),distance)    #if distances are equal only use minimum index\n                    else:\n                        distance_holder = (idx,distance)       #update distance holder\n                valid_pair.append(distance_holder)             #this was a remnant of brainstorming ways to solve problem , would need to refactor logic to remove this    \n            \n        if not valid_pair:                                     #checks if any elements are in valid pair\n            return -1\n        else:\n            return distance_holder[0]                #returns index\n\t\t\t```
['Python', 'Python3']