Sort native library paths for deterministic builds
Fixes #3800 by using a `BTreeSet`, which guarantees a deterministic iteration order.
Since the order was previously arbitrary, a sorted order is just as good. The list is so small, that any performance difference between `BTreeSet` and `HashSet` is negligible.