'Why does my Descending Bubble Sort not work for an input in ascending order?

This code works for most inputs except for when the input is in ascending order.

e.g. input is [1,2,3,4,5], output is [5,1,4,2,3], expected is [5,4,3,2,1]

DescBubbleSort(A) 
    for i from n downto 1 do
        for j from n downto i + 1 do
            if A[j] > A[j − 1] then
                A[j] swap A[j-1]
    return A


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source