python为什么使用sorted和sort输出结果不一样

在刷算法题的时候碰到了一个问题
Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.

        B = []
        for n in A:
            B.append(n**2)
        return B.sort()

    B = []
        for n in A:
            B.append(n**2)
        return sorted(B)

输出结果不一样是为什么
第一个B.sort()输出是[]空列表

因为sort()表示整理该列表,返回None,sorted表示返回整理后的列表
B.sort()相当于B=sorted(B)
如果你一定要用sort,就先B.sort()再return B