common.py 文件源码

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

项目:Helix 作者: 3lackrush 项目源码 文件源码
def prioritySortColumns(columns):
    """
    Sorts given column names by length in ascending order while those containing
    string 'id' go first

    >>> prioritySortColumns(['password', 'userid', 'name'])
    ['userid', 'name', 'password']
    """

    _ = lambda x: x and "id" in x.lower()
    return sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号