How to find a closest entry in an array using system verilog

In reply to uvm_va_1:

A.min() with (item<x? x-item: item-x)

Note that this returns an array with one element, or an empty array when A is empty.