def _value_sorter(feature_value):
  """Custom sorting function taking into account the structure of values.

  Given a feature value extracts its numeric portion, e.g.
    "18 ObligDoubleNeg" -> "18".

  Args:
    feature_value: (string) WALS feature value.

  Returns:
    An integer corresponding to the first portion of the string.
  """
  toks = feature_value.split(" ", maxsplit=1)
  assert len(toks) == 2, "%s: Invalid feature value" % feature_value
  val = int(toks[0])
  assert val > 0, "%s: Feature value should be positive. Found %d" % (
      feature_value, val)
  return val