def phone_to_num(phone_values):
"""Converts all phone strings into numerical values.
This helper function iterates over a set of different phones and returns an
alphabetically orderd directory where the phone string is the key and the
numerical value is the corrosponding value.
:params phone_values: a set (or list) of phone values
:returns: an ordered directory with the numerical values as values
"""
phone_values = OrderedDict.fromkeys(sorted(phone_values))
for i,k in enumerate(phone_values.keys()):
phone_values[k] = i
phone_values['None'] = -1
return phone_values
评论列表
文章目录