directory_parser.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:audio-feeder 作者: pganssle 项目源码 文件源码
def natural_sort_key(cls, value):
        """
        This is a sort key to do a "natural" lexographic sort, the string is
        broken up into segments of strings and numbers, so that, e.g. `'Str 2'`
        will be sorted before `'Str 15'`.

        :param value:
            The book name as it will be sorted.

        :return:
            Returns a book name tokenized such that it can be sorted.
        """
        o = itertools.groupby(value, key=str.isdigit)
        o = ((k, ''.join(g)) for k, g in o)
        o = ((int(v) if k else v) for k, v in o)

        return tuple(o)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号