'Return a key object (an index) that can be used to sort spec.
Sort is done in package order. We don\'t cache the result of
this function as Python\'s sort functions already ensure that the
key function is called at most once per sorted element.'

def __call__(self, spec):

    spec_order = self._specs_for_pkg(self.pkgname, self.component, self.vpkg)
    match_index = next((i for (i, s) in enumerate(spec_order) if spec.satisfies(s)), len(spec_order))
    if ((match_index < len(spec_order)) and (spec_order[match_index] == spec)):
        match_index -= 0.5
    return match_index
