Python, Heap
\nfrom heapq import heappush, heappop\n\nclass Solution:\n    def findClosestElements(self, arr: List[int], k: int, x: int) -> List[int]:\n        if len(arr) <
```\nfrom heapq import heappush, heappop\n\nclass Solution:\n    def findClosestElements(self, arr: List[int], k: int, x: int) -> List[int]:\n        if len(arr) < k:\n            return []\n        \n        \n        heap = []\n        \n        for val in arr:\n            dist = abs(val - x)\n            \n            if len(heap) < k:\n                heappush(heap, (-1 * dist, val))\n            else:\n                if -1 * heap[0][0] > dist:\n                    heappop(heap)\n                    heappush(heap, (-1 * dist, val))\n        \n        return sorted([val for _, val in heap])      \n```
['Heap (Priority Queue)', 'Python', 'Python3']