thiagowfx's avatar

¬ just serendipity 🍀 (not just serendipity)

LeetCode #3667: Sort Array By Absolute Value

• 21 words • 1 min

LeetCode #3667: Sort Array By Absolute Value:

python
class Solution:
    def sortByAbsoluteValue(self, nums: List[int]) -> List[int]:
        return list(sorted(nums, key=lambda x: abs(x)))