  Consider a finite set $E$. Assume that each $e \in E$ has a "weight" $w
\left(e\right) \in \mathbb{R}$ assigned to it, and any two distinct $e, f \in
E$ have a "distance" $d \left(e, f\right) = d \left(f, e\right) \in \mathbb{R}$
assigned to them, such that the distances satisfy the ultrametric triangle
inequality $d(a,b)\leqslant \max \left\{d(a,c),d(b,c)\right\}$. We look for a
subset of $E$ of given size with maximum perimeter (where the perimeter is
defined by summing the weights of all elements and their pairwise distances).
We show that any such subset can be found by a greedy algorithm (which starts
with the empty set, and then adds new elements one by one, maximizing the
perimeter at each step). We use this to define numerical invariants, and also
to show that the maximum-perimeter subsets of all sizes form a strong greedoid,
and the maximum-perimeter subsets of any given size are the bases of a matroid.
This essentially generalizes the "$P$-orderings" constructed by Bhargava in
order to define his generalized factorials, and is also similar to the strong
greedoid of maximum diversity subsets in phylogenetic trees studied by Moulton,
Semple and Steel.
  We further discuss some numerical invariants of $E, w, d$ stemming from this
construction, as well as an analogue where maximum-perimeter subsets are
replaced by maximum-perimeter tuples (i.e., elements can appear multiple
times).
