def _sort_alphanumerically_remove_leading_articles(self, val): """ Convert: 'The title' => 'title' 'A title' => 'title' 'Title' => 'title' """ if not val: return '' val = decode_to_unicode(val).lower().encode('UTF-8') val_tokens = val.split(" ", 1) #split in leading_word, phrase_without_leading_word if len(val_tokens) == 2 and val_tokens[0].strip() in LEADING_ARTICLES: return val_tokens[1].strip() return val.strip()
def _sort_case_insensitive(self, val): """Conversion to lower case""" if not val: return '' return decode_to_unicode(val).lower().encode('UTF-8')